pd_to_psql does not work if your data has comma in it
danielpoon opened this issue · 2 comments
The library works well with data columns that doesn't have commas but if you have a comma that's like a name e.g. "Smith, John", and then you try doing pd_to_psql, you will get the error below.
Any thoughts?
DataError Traceback (most recent call last)
in
----> 8 d6tstack.utils.pd_to_psql(df, fast_engine, 'xxx', 'xxx', if_exists='append')
9
10
/usr/local/lib/python3.7/site-packages/d6tstack/utils.py in pd_to_psql(df, uri, tablename, schema_name, if_exists)
122 df.to_csv(fbuf, index=False, header=False)
123 fbuf.seek(0)
--> 124 cursor.copy_from(fbuf, tablename, sep=',', null='')
125 sql_cnxn.commit()
126 cursor.close()
DataError: extra data after last expected column
CONTEXT: COPY xxxx, line 1:
Good point, new version in master d6tstack.utils.pd_to_psql(df,uri,'table',sep='\t')
. Reopen if it doesn't work
Upgraded to 0.14, still same error, had to revert to pd.to_sql for now, super slow but works.
I see that you changed the separator from tab. Is there something else?