Read a CSV file line by line
Source code name: "io_csv_read.py"
Programming language: Python
Topic: File IO/CSV
DMelt Version 1. Last modified: 12/10/2015. License: Free
http://datamelt.org/code/cache/io_csv_read_4201.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



from jhplot.io.csv import *

print "Writing file.."
w=CSVWriter("table.csv",',')
a1=['Test1','20','30']
w.writeNext(a1)
a2=['Test2','100','50']
w.writeNext(a2)
a3=['Test3','200','100']
w.writeNext(a3)
w.close()


print "Reading CSV file.."
r=CSVReader("table.csv",',')
while 1:
 line= r.readNext()
 if line == None: break
 print line
r.close()