question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add DataPackage.push method

See original GitHub issue

I can load Data Packages via URLs from data.okfn.org (e.g. http://data.okfn.org/data/core/cpi/datapackage.json) or from within the working directory (e.g. “.”). I am having trouble, though, loading directly from GitHub (‘https://raw.githubusercontent.com/datasets/cpi/master/datapackage.json’) or anywhere else on the filesystem.

In my case, loading works well:

import datapackage
dp = datapackage.DataPackage('https://raw.githubusercontent.com/datasets/cpi/master/datapackage.json')

But when I try to push to e.g. an SQL database using:

push_datapackage(descriptor=dp.metadata,backend='sql',engine=engine)

I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/dan/open_knowledge/envs/tutorial/lib/python3.5/site-packages/datapackage/pushpull.py", line 53, in push_datapackage
    data = resource.iter()
  File "/Users/dan/open_knowledge/envs/tutorial/lib/python3.5/site-packages/datapackage/resource.py", line 297, in iter
    raise IOError('Resource\'s data couldn\'t be loaded.')
OSError: Resource's data couldn't be loaded.

For the above example of loading from https://raw.githubusercontent.com/datasets/cpi/master/datapackage.json, it seems to be trying to load directly from non-existent “data/cpi.csv” in the working directory and not “https://raw.githubusercontent.com/datasets/cpi/master/data/cpi.csv

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
vitorbaptistacommented, May 6, 2016

@rgrp Just to add to what @roll said, the problem here is that @danfowler was passing dp.metadata, which is just a dict. There’s no indication of where it came from. However, the DataPackage instance itself knows its base path and can calculate relative paths for the resources, which is why I think the push_datapackage and pull_datapackage needs to live inside the DataPackage class.

1reaction
vitorbaptistacommented, May 3, 2016

I think this is a weak point of the current design. The push and pull datapackage methods don’t fit with the rest of the code structure yet. Ideally, this should work:

import datapackage
dp = datapackage.DataPackage('https://raw.githubusercontent.com/datasets/cpi/master/datapackage.json')
dp.push(backend='sql', engine=engine)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Push elements in a list or vector in datapackage.r - Rdrr.io
Helper function to add components in a list or vector.
Read more >
Push (Tabular) Data Package to AWS Redshift · Issue #128 ... - GitHub
Push (Tabular) Data Package to AWS Redshift #128. Closed ... Add DataPackage.push method frictionlessdata/datapackage-py#75. Closed.
Read more >
datapackage - npm
A class for working with data resources. You can read or iterate tabular resources using the iter/read methods and all resource as bytes...
Read more >
Using Data Packages in Python
Short examples of pushing your dataset to Google's BigQuery and Amazon's RedShift ... For this tutorial, we will need the main Python Data...
Read more >
File: README — Documentation for datapackage (1.1.1)
Validating data packages to ensure they conform with the Data Package specification. Installation. Add the gem into your Gemfile: gem 'datapackage.rb'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found