datahq / dataflows

DataFlows is a simple, intuitive lightweight framework for building data processing flows in python.
https://dataflows.org
MIT License
194 stars 39 forks source link

Error iterating resource: File not found in Resource Path. #105

Closed avdata99 closed 4 years ago

avdata99 commented 4 years ago

Dataflow error:

I'm using CKAN API results with DataFlows.
Just yielding each dataset.

But this resource fails when I want to iterate over it.
I get the resource.

And get an error reading.

FileNotFoundError: [Errno 2] No such file or directory: './res_1.csv'

(same error with iter or read(keyed=True))

LOG

Extracting from harvest source id: 50ca39af-9ddb-466d-8cf3-84d67a204346
PAGE 1 from harvest source id: 50ca39af-9ddb-466d-8cf3-84d67a204346
--------------------------------
Package processor
Package: <dataflows.base.package_wrapper.PackageWrapper object at 0x7f81c1634898>
 - Resource: {'name': 'ckan_results', 'path': 'res_1.csv', 'profile': 'tabular-data-resource', 'total_fields': 32, 'fields': [{'name': 'license_title', 'type': 'string', 'format': 'default'}, {'name': 'maintainer', 'type': 'string', 'format': 'default'}, {'name': 'relationships_as_object', 'type': 'array', 'format': 'default'}, {'name': 'private', 'type': 'integer', 'format': 'default'}, {'name': 'maintainer_email', 'type': 'string', 'format': 'default'}, {'name': 'num_tags', 'type': 'integer', 'format': 'default'}, {'name': 'id', 'type': 'string', 'format': 'default'}, {'name': 'metadata_created', 'type': 'string', 'format': 'default'}, {'name': 'metadata_modified', 'type': 'string', 'format': 'default'}, {'name': 'author', 'type': 'string', 'format': 'default'}, {'name': 'author_email', 'type': 'string', 'format': 'default'}, {'name': 'state', 'type': 'string', 'format': 'default'}, {'name': 'version', 'type': 'any', 'format': 'default'}, {'name': 'creator_user_id', 'type': 'string', 'format': 'default'}, {'name': 'type', 'type': 'string', 'format': 'default'}, {'name': 'resources', 'type': 'array', 'format': 'default'}, {'name': 'num_resources', 'type': 'integer', 'format': 'default'}, {'name': 'tags', 'type': 'array', 'format': 'default'}, {'name': 'tracking_summary', 'type': 'object', 'format': 'default'}, {'name': 'groups', 'type': 'array', 'format': 'default'}, {'name': 'license_id', 'type': 'string', 'format': 'default'}, {'name': 'relationships_as_subject', 'type': 'array', 'format': 'default'}, {'name': 'organization', 'type': 'object', 'format': 'default'}, {'name': 'name', 'type': 'string', 'format': 'default'}, {'name': 'isopen', 'type': 'integer', 'format': 'default'}, {'name': 'url', 'type': 'any', 'format': 'default'}, {'name': 'notes', 'type': 'string', 'format': 'default'}, {'name': 'owner_org', 'type': 'string', 'format': 'default'}, {'name': 'extras', 'type': 'array', 'format': 'default'}, {'name': 'license_url', 'type': 'string', 'format': 'default'}, {'name': 'title', 'type': 'string', 'format': 'default'}, {'name': 'revision_id', 'type': 'string', 'format': 'default'}]}
--------------------------------
--------------------------------
Package processor
Package: <dataflows.base.package_wrapper.PackageWrapper object at 0x7f81c14e3518>
 - Resource: {'name': 'ckan_results', 'path': 'res_1.csv', 'profile': 'tabular-data-resource', 'total_fields': 32, 'fields': [{'name': 'license_title', 'type': 'string', 'format': 'default'}, {'name': 'maintainer', 'type': 'string', 'format': 'default'}, {'name': 'relationships_as_object', 'type': 'array', 'format': 'default'}, {'name': 'private', 'type': 'integer', 'format': 'default'}, {'name': 'maintainer_email', 'type': 'string', 'format': 'default'}, {'name': 'num_tags', 'type': 'integer', 'format': 'default'}, {'name': 'id', 'type': 'string', 'format': 'default'}, {'name': 'metadata_created', 'type': 'string', 'format': 'default'}, {'name': 'metadata_modified', 'type': 'string', 'format': 'default'}, {'name': 'author', 'type': 'string', 'format': 'default'}, {'name': 'author_email', 'type': 'string', 'format': 'default'}, {'name': 'state', 'type': 'string', 'format': 'default'}, {'name': 'version', 'type': 'any', 'format': 'default'}, {'name': 'creator_user_id', 'type': 'string', 'format': 'default'}, {'name': 'type', 'type': 'string', 'format': 'default'}, {'name': 'resources', 'type': 'array', 'format': 'default'}, {'name': 'num_resources', 'type': 'integer', 'format': 'default'}, {'name': 'tags', 'type': 'array', 'format': 'default'}, {'name': 'tracking_summary', 'type': 'object', 'format': 'default'}, {'name': 'groups', 'type': 'array', 'format': 'default'}, {'name': 'license_id', 'type': 'string', 'format': 'default'}, {'name': 'relationships_as_subject', 'type': 'array', 'format': 'default'}, {'name': 'organization', 'type': 'object', 'format': 'default'}, {'name': 'name', 'type': 'string', 'format': 'default'}, {'name': 'isopen', 'type': 'integer', 'format': 'default'}, {'name': 'url', 'type': 'any', 'format': 'default'}, {'name': 'notes', 'type': 'string', 'format': 'default'}, {'name': 'owner_org', 'type': 'string', 'format': 'default'}, {'name': 'extras', 'type': 'array', 'format': 'default'}, {'name': 'license_url', 'type': 'string', 'format': 'default'}, {'name': 'title', 'type': 'string', 'format': 'default'}, {'name': 'revision_id', 'type': 'string', 'format': 'default'}]}
 - Resource: {'name': 'comparison_results', 'path': None, 'profile': 'tabular-data-resource', 'total_fields': 4, 'fields': [{'name': 'action', 'type': 'string', 'format': 'default'}, {'name': 'ckan_id', 'type': 'string', 'format': 'default'}, {'name': 'new_data', 'type': 'object', 'format': 'default'}, {'name': 'reason', 'type': 'string', 'format': 'default'}]}
--------------------------------
CKAN res: ckan_results: 
    headers:None, 
    schema:<tableschema.schema.Schema object at 0x7f81c15d5630>, 
    inline:False, 
    tabular:True 
Traceback (most recent call last):
  File "/home/hudson/envs/data_json_etl/lib/python3.6/site-packages/tabulator/loaders/local.py", line 36, in load
    bytes = io.open(source, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: './res_1.csv'
akariv commented 4 years ago

Dataflows process data as a stream of rows - I think you're assuming the steps run one after the other, but it's not the case.

To do what you're trying to do, I would simply load the two lists of datasets and then use join to check which ones match and which ones don't.

avdata99 commented 4 years ago

Thanks Adam