For me, it was a bit different case.
I loaded my dataframe as such:
my_converter = {'filename': str, 'revision_id': int}
df = pd.read_csv("my.csv", header=0, sep="\t", converters=my_converter)
becuase head -n 3 my.csv
looked like so:
"filename" "revision_id"
"some_filename.pdf" "224"
"another_filename.pdf" "128"
However, down thousands of lines, there was an entry like this:
"very_\"special\"_filename.pdf" "46"
which meant that I had to specify the escape character to the read_csv()
. Else, it would try to cast special
as int
for the revision_id
field and generate the error.
So the correct way is to:
df = pd.read_csv("my.csv", header=0, sep="\t", escapechar='\\', converters=my_converter)