problem reading a csv file in python
Posted
by Hossein
on Stack Overflow
See other posts from Stack Overflow
or by Hossein
Published on 2010-06-16T21:37:32Z
Indexed on
2010/06/16
21:42 UTC
Read the original article
Hit count: 187
python
Hi, I am trying to read a very simple but somehow large(800Mb) csv file using the csv library in python. The delimiter is a single tab and each line consists of some numbers. Each line is a record, and I have 20681 rows in my file. I had some problems during my calculations using this file,it always stops at a certain row. I got suspicious about the number of rows in the file.I used the code below to count the number of row in this file:
tfdf_Reader = csv.reader(open('v2-host_tfdf_en.txt'),delimiter=' ')
c = 0
for row in tfdf_Reader:
c = c + 1
print c
To my surprise c is printed with the value of 61722!!! Why is this happening? What am I doing wrong?
© Stack Overflow or respective owner