On May 26, 4:49 am, cjl <cjl...@gmail.comwrote:
P:
Stupid question:
reader = csv.reader(open('somefile.csv'))
for row in reader:
do something
Any way to determine the "length" of the reader (the number of rows)
before iterating through the rows?
-CJL
Of course not. A CSV file (even without the embedded newline
complication mentioned by Peter) is a file of variable-length records
separated by a one-or-two-character sequence. Modern Python-supported
filesystems' directories don't keep the information that would be
required to tell you whether a file's records are fixed or variable
length, let alone how many "records" there are in a file.
Why are you asking? Perhaps if you tell us what you are trying to
achieve, we can help you.
Cheers,
John