xmunoz / sodapy

Python client for the Socrata Open Data API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Confusing error for csv upsert

James-OHara opened this issue · comments

I'm using SodaPy to do a simple upsert of a data file to an empty dataset (contains columns but no data). However, I'm getting a confusing error message that Socrata cannot recognize the payload type file, even though that's supposed to be supported. This is a properly formatted comma-separated file with Unix line endings. Traceback of the error in Python 2.7 is below. The error is Python 3 is different and attached here.

Traceback (most recent call last):
File "dtg_data_upload.py", line 21, in
conn.upsert("8ect-6jqj ", uploadcsv)
File "C:\Python27\lib\site-packages\sodapy_init_.py", line 249, in upsert
return self.perform_update("post", resource, payload)
File "C:\Python27\lib\site-packages\sodapy_init
.py", line 307, in _perform_update
" and file-types are supported.".format(type(payload)))
Exception: Unrecognized payload <type 'file'>. Currently only list-, dictionary-, and file-types are supported.
python3error.txt

Thanks for letting me know! This probably never worked in python2. I've pushed a short-term fix for you here. Unfortunately this is not python3 compatible, so I cannot release it this way. Once I figure out a solution that works for both, I'll roll a new version.

Thank you!

Just finished releasing the bugfix. Enjoy!