Boomer boomer4467 at
Sat Jan 3 21:49:56 CET 2004

Hi all,
    I'm new to python which explains my problems with this. I'm trying
to import a .csv file(from excel) into some fields on my company's
software system(which interfaces to an sql database. Each row in this
.csv file needs to be split into smaller strings and each respective
string applied to it's field in the software then it's saved and the
next row starts, here's the code I've come up with so far.

f=open ("book1.csv", "r")
s=f.readline ()
while s != "":
  print s
  l = s.split(s,",",(11))
  PlayIt.SetFieldContent ("SY012M1", "art-nr", l[0])
  PlayIt.PlayContent ("{CSB SY012M1|art-nr}{Enter}")
  PlayIt.SetFieldContent ("SY012ADM1", "001bez",  l[1])
  PlayIt.SetFieldContent ("SY012ADM1", "005agr",  l[2])
  PlayIt.SetFieldContent ("SY012ADM1", "006agr",  l[3])
  PlayIt.SetFieldContent ("SY012ADM1", "009kst",  l[4])
  PlayIt.SetFieldContent ("SY012EHM1", "005laeh",  l[5])
  PlayIt.SetFieldContent ("SY012EHM1", "006lauf",   l[6])
  PlayIt.SetFieldContent ("SY012EHM1", "011vkuf",   l[7])
  PlayIt.SetFieldContent ("SY012SDM1", "012fest",   l[8])
  PlayIt.SetFieldContent ("SY012PRM1", "001tpr",   l[9])
  PlayIt.SetFieldContent ("SY012PRM1", "002wpr",   l[10])
  PlayIt.SetFieldContent ("SY012PRM1", "003plpr",   l[11])
  PlayIt.PlayContent ("{CSB SY012M1|art-nr}{F2}")
  s=f.readline ()
f.close ()

here's the error

Traceback (innermost last):
  File "<string>", line 5, in ?
AttributeError: 'string' object has no attribute 'split'

the furthest I get is when I remove the s.split all together then I
can actually watch it import the first field correctly and switch
focus to the second field where it prints a comma and then hangs and
eventually gives the
argument 3: expected string list found
Someone told me I need to import the string module using "import
string" somewhere in my code, but when I do this I get an error
stating that no such module exists. I run this as script inside a
macro from another program and I believe the version of python this
program uses is 2.2.1.

Does anyone have any ideas? Any help would be wonderful!!!

More information about the Python-list mailing list