How to count CSV file rows

1152330 pts.
Tags:
CSV file
For the life of me, I can't figure out what my issue is with this question. I'm trying to count the number of lines (rows in my CSV file). I have 500 but row_count=0. Here's the code I have:
f = open(adresse,"r")
reader = csv.reader(f,delimiter = ",")
data = [l for l in reader]
row_count = sum(1 for row in reader)

print row_count
Can anyone help?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

I will assume that is Phyton code.

Try removing the line:

data = [l for l in reader]

As it is probably what is causing the problem when you perform the count after that.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: