How to read single values that contains commas in csv file using python -
i have csv file contains following values
"spam2,pank",spam3,spam6,spam7 spam1,spam5,spam0,spam9 and using following python code read particular column
for line in open('d:\eggs2.csv','rb'): columns = line.split(",") print columns[0] the output gives is:-
"spam2 spam1 while expecting :
spam2,pank spam1 please me out on this.
you don't have reinvent wheel, python csv module perfect job.
import csv csv_file = open('d:\eggs2.csv','rb') csv_reader = csv.reader(csv_file) row in csv_reader: print row[0] csv_file.close() @see python csv
Comments
Post a Comment