[Tutor] importing into fields

Chris Rosenboom boomer4467 at yahoo.com
Fri Jan 2 18:32:35 EST 2004


I'm trying to manipulate a string to seperate before entering each seperate instance in some fields on a software program, here's an example of the script
 
f=open ("book2.txt", "r")
s=f.readline ()
while s != "":
  print s
  l = string.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 ()
 
this is the error returned:
 
Traceback (innermost last):
  File "<string>", line 5, in ?
NameError: string

 
I've also tried this in line 5
 
l = (s, ",",[11])
 
I get further with this I actually get the first part of the string in the first field like it should be but in the second field all i get is a comma and it freezes, Initially I've been trying to import this from a csv file and now I've been working with text files. I'm sure I just don't know how to manipulate the string and I'm having trouble finding descriptions and methods to use with a string object. Do you have any suggestions or anything that would be helpful?
Thank You,
 
Chris Rosenboom




---------------------------------
Do you Yahoo!?
Find out what made the Top Yahoo! Searches of 2003
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040102/5ec7f14a/attachment.html


More information about the Tutor mailing list