You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the client to request items but I would like to limit them because some of the fields are way too big. So I only need a few fields but I want all the items. For example, this works fine for CSV if I declare the fields parameter:
Well, there's no error, but we get all the fields instead of just the two we request, effectively the fields parameter is ignored.
So maybe we could patch scrapinghub/hubstorage/resourcetype.py:apirequest() to check for the csv format to bypass the json decoding but it would actually be better if the backend api supported this field subset declaration for other formats, namely json.
I see that the api supports max_fields and we know that csv supports field limiting so maybe it's not a big deal to get the api to support field limiting for json as well.
The text was updated successfully, but these errors were encountered:
Thanks for the report, Steven! So there're 2 issues in fact:
JSON exporter ignores fields parameter - as it should be fixed server-side, I created an inner ticket for fix this when we have resources
job.items.list doesn't handle exporting data in CSV and yeah, it's something that we could improve in the library itself. However I think a better way would be to avoid overloading of existing list method and to add a separate method for this, like job.items.export handling same set of filters as list method and returning a string, or maybe dumping it to a file.
vshlapakov
changed the title
Cannot get a limited fields subset
Allow to export items data in CSV format
Sep 17, 2018
stav
changed the title
Allow to export items data in CSV format
Allow exporting items data in CSV format
Sep 17, 2018
I am using the client to request items but I would like to limit them because some of the fields are way too big. So I only need a few fields but I want all the items. For example, this works fine for CSV if I declare the
fields
parameter:But when I try it with the client I get:
Ok, so let's try without
msgpack
:So the problem is that the response is assumed by the client to be JSON and it tries to decode the string:
Ok, let's try it with json now:
Well, there's no error, but we get all the fields instead of just the two we request, effectively the
fields
parameter is ignored.So maybe we could patch
scrapinghub/hubstorage/resourcetype.py:apirequest()
to check for the csv format to bypass the json decoding but it would actually be better if the backend api supported this field subset declaration for other formats, namely json.I see that the api supports
max_fields
and we know that csv supports field limiting so maybe it's not a big deal to get the api to support field limiting for json as well.The text was updated successfully, but these errors were encountered: