Created
September 28, 2016 09:16
-
-
Save is/0302caf85970a09f54c0e3e0b89c619e to your computer and use it in GitHub Desktop.
python read data from a csv file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a | b | |
|---|---|---|
| 1 | 2 | |
| 3 | 4 | |
| 5 | 6 | |
| c | d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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