Skip to content

Instantly share code, notes, and snippets.

@is
Created September 28, 2016 09:16
Show Gist options
  • Select an option

  • Save is/0302caf85970a09f54c0e3e0b89c619e to your computer and use it in GitHub Desktop.

Select an option

Save is/0302caf85970a09f54c0e3e0b89c619e to your computer and use it in GitHub Desktop.
python read data from a csv file
import csv
fin = file('d1.csv', 'rb')
cin = csv.reader(fin)
cin.next() # skip header
for row in cin:
print row[0] # first colume
print row[1] # second colume
print "--"
fin.close()
a b
1 2
3 4
5 6
c d
1
2
--
3
4
--
5
6
--
c
d
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment