The csv module of Python (2.3+)

I read and write csv (or tsv) files everyday. For quite a while, I have been using my own csv file reader and writer, without known that Python itself provides CSV reader and writer. In case you don't know, here is it: http://docs.python.org/library/csv.html

Now I can easily create a list out of a CSV file.
csvreader = csv.reader(open('test.tsv','r'), delimiter='\t')
x = []
for row in csvreader:
    x.append(row)

However, I notice that csv.writer() has some strange problem on my Linux box. Sometimes it does not finish writing the list. I don't know why.

No comments: