strange problem

K

ken

This file has 1,000,000+ lines in it, yet when I print the counter 'cin'
at EOF I get around 10,000 less lines. Any ideas?

lineIn =
csv.reader(file("rits_feed\\rits_feed_US.csv",'rb'),delimiter='|')
for emp in lineIn:
cin=cin+1
print cin
 
T

Tim Chase

This file has 1,000,000+ lines in it, yet when I print the counter 'cin'
at EOF I get around 10,000 less lines. Any ideas?

lineIn =
csv.reader(file("rits_feed\\rits_feed_US.csv",'rb'),delimiter='|')
for emp in lineIn:
cin=cin+1
print cin

What happens if you open it in ascii mode rather than binary mode?

-tkc
 
B

Bruno Desthuilliers

ken a écrit :
This file has 1,000,000+ lines in it, yet when I print the counter 'cin'
at EOF I get around 10,000 less lines. Any ideas?

Not without seeing the file.
But I'm not sure I want to see it !-)
lineIn =
csv.reader(file("rits_feed\\rits_feed_US.csv",'rb'),delimiter='|')
for emp in lineIn:
cin=cin+1
print cin

Note that manually tracking line count/number is way too boring. That's
why Python as enumerate(seq) => indice, item
 
S

Steve Holden

ken said:
This file has 1,000,000+ lines in it, yet when I print the counter 'cin'
at EOF I get around 10,000 less lines. Any ideas?

lineIn =
csv.reader(file("rits_feed\\rits_feed_US.csv",'rb'),delimiter='|')
for emp in lineIn:
cin=cin+1
print cin

My psychic powers indicate that double-quotes in the data are the most
likely source of your problem. You may need to extract some statistics
from the data to find out what's going on without examining each record
individually.

Like, for example, longest field-length for each column.

regards
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top