Mostly Linux & Python syntax notes and hyperlinks.

Thursday, August 12, 2010

python: iterating through csv.reader record

import csv

myReader=csv.reader(open(file_name,"rb"),delimiter='\t', quoting=csv.QUOTE_NONE) 

for record in myReader:
    print("len(record)="+str(len(record))
    for i in range(len(record)):
        print("record " + str(i) + "=" + record[i])

Though watch for Error Message
"not all arguments converted during string formatting"

python: printing more than one integer in a string

>>> a=5
>>> b=6
>>> c=7
>>>print("a=%d,b=%d,c=%d" % (a,b,c))

a=5,b=6,c=7