Advertisement
Guest User

Iterate over CSV rows in a file

a guest
Mar 30th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. import csv
  3.  
  4. my_path = 'Insert here the path to your file'
  5.  
  6. with open(os.path.join(my_path, 'file_name.csv'), 'rb') as my_file:
  7.     my_file_reader = cvs.reader(my_file)
  8.     for row in my_file_reader:
  9.         print row # or test something else
  10.  
  11. # PS: Credits to RealPython where I learnt the above algorithm ;)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement