write csv to object and read into pandas
Vincent Davis
vincent at vincentdavis.net
Thu Oct 15 01:24:41 EDT 2015
I have a csv file I have to make some changes to before I read it into
pandas. Currently I open the csv read each row, make changes and save it to
a new file. Then read it into pandas with pandas.read_csv(). How do I skip
writing the file to disk? Using python3.5.
This is what I am doing now.
with open(infile,"r") as fin:
with open(outfile,"w") as fout:
writer=csv.writer(fout)
for row in csv.reader(fin):
#do stuff to the row
writer.writerow(row)
df = pandas.csv_reader(outfile)
Vincent Davis
720-301-3003
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20151014/5fafb2b5/attachment.html>
More information about the Python-list
mailing list