read_csv from list of strings

33 views
Skip to first unread message

beli...@aol.com

unread,
Jan 2, 2017, 12:47:08 PM1/2/17
to PyData
I want to read a dataframe from a file whose data is not in the right format -- there are dollar signs in some fields
and some extra lines at the end. Can I read the read the file into a list of strings, modify those strings,
and then use read_csv on that list? Or do I need to write the modified list of strings to a temporary file that can 
be read? Thank you.

Miki Tebeka

unread,
Jan 2, 2017, 11:18:25 PM1/2/17
to PyData
You can use "skipfooter" to skip rows at the end of the line. After the DataFrame is loaded you can use df[col].str.replace('\$', '') to remove the $ signs.
Reply all
Reply to author
Forward
0 new messages