Created
October 3, 2012 18:04
-
-
Save language-engineering/3828658 to your computer and use it in GitHub Desktop.
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 | |
| #Provide a list, where every element in the list corresponds to a row of the spreadsheet | |
| #Every element in the list is another list, whose elements correspond to the columns of that row | |
| data = [[2,3,3],[4,3,5],[2,1,4]] | |
| #Write the data to a CSV file, which a spreadsheet program can open | |
| with open("file_name.csv","wb") as outputfile: | |
| writer = csv.writer(outputfile) | |
| writer.writerows(data) | |
| #Read in the data of a CSV for further processing in Python | |
| with open("file_name.csv","rb") as inputfile: | |
| reader = csv.reader(inputfile) | |
| for row in reader: | |
| print row |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment