Sample CSV reader /Writer using pandas
import pandas,os
p="/home/deepak/Python/testData/1.csv"
sheet=pandas.DataFrame( {"rollno":[1,2],"name":["a",'b']})
sheet.to_csv(p)
if(os.path.exists(p)):
Obj=pandas.read_csv(p)
print(Obj.columns) #print all columns
print(Obj['name'][1]) #Print 1 row 1 col value
Obj.set_value(0,"name","deepak")
Obj.to_csv(p)
No comments:
Post a Comment