python - Row count in a csv file -


i making stupid mistake, can't find is. want count number of lines in csv file. wrote this, , isn't working: have row_count = 0 while should 400. cheers.

f = open(adresse,"r") reader = csv.reader(f,delimiter = ",") data = [l l in reader] row_count = sum(1 row in reader)  print row_count 

with open(adresse,"r") f:     reader = csv.reader(f,delimiter = ",")     data = list(reader)     row_count = len(data) 

you trying read file twice, when file pointer has reached end of file after saving data list.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -