importing

engsolnom at ipns.com engsolnom at ipns.com
Sat Jan 3 17:13:59 EST 2004


On 3 Jan 2004 12:49:56 -0800, boomer4467 at yahoo.com (Boomer) wrote:

>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])

I'm just a newbie, but I'll take a crack at it any way...

split returns a list, and takes either one or two args. If the the first arg is missing, it defaults
to setting the separator to while space. In your case, you might try:

l = s.split(',', 11)

Norm



More information about the Python-list mailing list