| 1 | initial version |
Here is one collection of some simple python code.
To read a data file, the file is stored with the Sage notebook in a directory labelled DATA by Sage.
import csv
data =list( csv.reader(open(DATA+'infile.csv','rU')) )
The data is then in a list that you can manipulate.
Some code for writing a list named info that contains lists is:
writefile = csv.writer(open(DATA+'outfile.csv', 'w'))
for i in range(0,len(info)):
writefile.writerow(info[i])
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.