469,286 Members | 2,500 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

strange problem

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
Oct 24 '06 #1
3 890
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


Oct 24 '06 #2
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

Oct 24 '06 #3
ken wrote:
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
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Oct 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Paul Drummond | last post: by
25 posts views Thread by Neil Ginsberg | last post: by
1 post views Thread by Sam Kong | last post: by
11 posts views Thread by Martin Joergensen | last post: by
8 posts views Thread by Dox33 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.