# datapackage-py
[![Travis](https://travis-ci.org/frictionlessdata/datapackage-py.svg?branch=master)](https://travis-ci.org/frictionlessdata/datapackage-py)
[![Coveralls](https://coveralls.io/repos/github/frictionlessdata/datapackage-py/badge.svg?branch=master)](https://coveralls.io/github/frictionlessdata/datapackage-py?branch=master)
[![PyPi](https://img.shields.io/pypi/v/datapackage.svg)](https://pypi.python.org/pypi/datapackage)
[![Github](https://img.shields.io/badge/github-master-brightgreen)](https://github.com/frictionlessdata/datapackage-py)
[![Gitter](https://img.shields.io/gitter/room/frictionlessdata/chat.svg)](https://gitter.im/frictionlessdata/chat)
A library for working with [Data Packages](http://specs.frictionlessdata.io/data-package/).
> **[Important Notice]** We have released [Frictionless Framework](https://github.com/frictionlessdata/frictionless-py). This framework provides improved `datapackage` functionality extended to be a complete data solution. The change in not breaking for the existing software so no actions are required. Please read the [Migration Guide](https://framework.frictionlessdata.io/docs/development/migration) from `datapackage` to Frictionless Framework.
> - we continue to bug-fix `datapackage@1.x` in this [repository](https://github.com/frictionlessdata/datapackage-py) as well as it's available on [PyPi](https://pypi.org/project/datapackage/) as it was before
> - please note that `frictionless@3.x` version's API, we're working on at the moment, is not stable
> - we will release `frictionless@4.x` by the end of 2020 to be the first SemVer/stable version
## Features
- `Package` class for working with data packages
- `Resource` class for working with data resources
- `Profile` class for working with profiles
- `validate` function for validating data package descriptors
- `infer` function for inferring data package descriptors
## Contents
<!--TOC-->
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Documentation](#documentation)
- [Introduction](#introduction)
- [Working with Package](#working-with-package)
- [Working with Resource](#working-with-resource)
- [Working with Group](#working-with-group)
- [Working with Profile](#working-with-profile)
- [Working with Foreign Keys](#working-with-foreign-keys)
- [Working with validate/infer](#working-with-validateinfer)
- [Frequently Asked Questions](#frequently-asked-questions)
- [API Reference](#api-reference)
- [`cli`](#cli)
- [`Package`](#package)
- [`Resource`](#resource)
- [`Group`](#group)
- [`Profile`](#profile)
- [`validate`](#validate)
- [`infer`](#infer)
- [`DataPackageException`](#datapackageexception)
- [`TableSchemaException`](#tableschemaexception)
- [`LoadError`](#loaderror)
- [`CastError`](#casterror)
- [`IntegrityError`](#integrityerror)
- [`RelationError`](#relationerror)
- [`StorageError`](#storageerror)
- [Contributing](#contributing)
- [Changelog](#changelog)
<!--TOC-->
## Getting Started
### Installation
The package use semantic versioning. It means that major versions could include breaking changes. It's highly recommended to specify `datapackage` version range in your `setup/requirements` file e.g. `datapackage>=1.0,<2.0`.
```bash
$ pip install datapackage
```
#### OSX 10.14+
If you receive an error about the `cchardet` package when installing datapackage on Mac OSX 10.14 (Mojave) or higher, follow these steps:
1. Make sure you have the latest x-code by running the following in terminal: `xcode-select --install`
2. Then go to [https://developer.apple.com/download/more/](https://developer.apple.com/download/more/) and download the `command line tools`. Note, this requires an Apple ID.
3. Then, in terminal, run `open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg`
You can read more about these steps in this [post.](https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave)
## Documentation
### Introduction
Let's start with a simple example:
```python
from datapackage import Package
package = Package('datapackage.json')
package.get_resource('resource').read()
```
### Working with Package
A class for working with data packages. It provides various capabilities like loading local or remote data package, inferring a data package descriptor, saving a data package descriptor and many more.
Consider we have some local csv files in a `data` directory. Let's create a data package based on this data using a `Package` class:
> data/cities.csv
```csv
city,location
london,"51.50,-0.11"
paris,"48.85,2.30"
rome,"41.89,12.51"
```
> data/population.csv
```csv
city,year,population
london,2017,8780000
paris,2017,2240000
rome,2017,2860000
```
First we create a blank data package:
```python
package = Package()
```
Now we're ready to infer a data package descriptor based on data files we have. Because we have two csv files we use glob pattern `**/*.csv`:
```python
package.infer('**/*.csv')
package.descriptor
#{ profile: 'tabular-data-package',
# resources:
# [ { path: 'data/cities.csv',
# profile: 'tabular-data-resource',
# encoding: 'utf-8',
# name: 'cities',
# format: 'csv',
# mediatype: 'text/csv',
# schema: [Object] },
# { path: 'data/population.csv',
# profile: 'tabular-data-resource',
# encoding: 'utf-8',
# name: 'population',
# format: 'csv',
# mediatype: 'text/csv',
# schema: [Object] } ] }
```
An `infer` method has found all our files and inspected it to extract useful metadata like profile, encoding, format, Table Schema etc. Let's tweak it a little bit:
```python
package.descriptor['resources'][1]['schema']['fields'][1]['type'] = 'year'
package.commit()
package.valid # true
```
Because our resources are tabular we could read it as a tabular data:
```python
package.get_resource('population').read(keyed=True)
#[ { city: 'london', year: 2017, population: 8780000 },
# { city: 'paris', year: 2017, population: 2240000 },
# { city: 'rome', year: 2017, population: 2860000 } ]
```
Let's save our descriptor on the disk as a zip-file:
```python
package.save('datapackage.zip')
```
To continue the work with the data package we just load it again but this time using local `datapackage.zip`:
```python
package = Package('datapackage.zip')
# Continue the work
```
It was onle basic introduction to the `Package` class. To learn more let's take a look on `Package` class API reference.
### Working with Resource
A class for working with data resources. You can read or iterate tabular resources using the `iter/read` methods and all resource as bytes using `row_iter/row_read` methods.
Consider we have some local csv file. It could be inline data or remote link - all supported by `Resource` class (except local files for in-brower usage of course). But say it's `data.csv` for now:
```csv
city,location
london,"51.50,-0.11"
paris,"48.85,2.30"
rome,N/A
```
Let's create and read a resource. Because resource is tabular we could use `resource.read` method with a `keyed` option to get an array of keyed rows:
```python
resource = Resource({path: 'data.csv'})
resource.tabular # true
resource.read(keyed=True)
# [
# {city: 'london', location: '51.50,-0.11'},
# {city: 'paris', location: '48.85,2.30'},
# {city: 'rome', location: 'N/A'},
# ]
resource.headers
# ['city', 'location']
# (reading has to be started first)
```
As we could see our locations are just a strings. But it should be geopoints. Also Rome's location is not available but it's also just a `N/A` string instead of Python `None`. First we have to infer resource metadata:
```python
resource.infer()
resource.descriptor
#{ path: 'data.csv',
# profile: 'tabular-data-resource',
# encoding: 'utf-8',
# name: 'data',
# format: 'csv',
# mediatype: 'text/csv',
# schema: { fields: [ [Object], [Object] ], missingValues: [ '' ] } }
resource.read(keyed=True)
# Fails with a data validation error
```
Let's fix not available location. There is a `missingValues` property in Table Schema specification. As a first try we set `missingValues` to `N/A` in `resource.descriptor.schema`. Resource descriptor could be changed in-place but all changes should be commited by `resource.commit()`:
```python
resource.descriptor['schema']['missingValues'] = 'N/A'
resource.commit()
resource.valid # False
resource.errors
# [<ValidationError: "'N/A' is not of type 'array'">]
```
As a good citiziens we've decided to check out recource descriptor validity. And it's not valid! We should use an array for `missingValues` property. Also don't forget to have an empty string as a missing value:
```python
resource.descriptor['schema']['missingValues'] = ['', 'N/A']
resource.commit()
resource.valid # true
```
All good. It looks like we're ready to read our data again:
```python
resource.read(keyed=True)
# [
# {city: 'london', location: [51.50,-0.11]},
# {city: 'paris', location: [48.85,2.30]},
# {city: 'rome', location: null},
# ]
```
Now we see that:
- locations are arrays with numeric lattide and longitude
- Rome's location is a native JavaScript `null`
And because there are no errors on data reading we could be sure that our data is valid againt our schema. Let's save our resource descriptor:
```python
resource.save('dataresource.json')
```
Let's check newly-crated `dataresource.json`. It contains path to our data file, inferred metadata and our `missingValues` tweak:
```json
{
"path": "data.csv",
"profile": "tabular-data-resource",
"encoding": "utf-8",
"name": "data",
"format": "csv",
"mediatype": "text/csv",
"schema": {
"fields": [
{
"name": "city",
"type": "string",
"format": "default"
},
{
"name": "location",
"type": "geopoint",
"format": "default"
}
],
"missingValues": [
"",
"N/A"
]
}
}
```
If we decide to improve it even more we could update the `dataresource.json` file and then open it again using local file name:
```python
resource = Resource('dataresource.json')
# Continue the work
```
It was onle basic introduction to the `Resource` class. To learn more let's take a look on `Resource` class API reference.
### Working with Group
A class representing a group of tabular resources. Groups can be used to read multiple resource as one or to export them, for example, to a database as one table. To define a group add the `group: <name>` field to corresponding resources. The group's metadata will be created from the "leading" resource's metadata (the first resource with the group name).
Consider we have a data package with two tables partitioned by a year and a shared schema stored separately:
> cars-2017.csv
```csv
name,value
bmw,2017
tesla,2017
nissan,2017
```
> cars-2018.csv
```csv
name,value
bmw,2018
tesla,2018
nissan,2018
```
> cars.schema.json
```json
{
"fields": [
{
"name": "name",
"type": "string"
},
{
"name": "value",
"type": "integer"
}
]
}
```
> datapackage.json
```json
{
"name": "datapackage",
"resources": [
{
"group": "cars",
"name": "cars-2017",
"path": "cars-2017.csv",
"profile": "tabular-data-resource",
"schema": "cars.schema.json"
},
{
"group": "cars",
"name": "cars-2018",
"path": "cars-2018.csv",
"profile": "tabular-data-resource",
"schema": "cars.schema.json"
}
]
}
```
Let's read the resources separately:
```python
package = Package('datapackage.json')
package.get_resource('cars-2017').read(keyed=True) == [
{'name': 'bmw', 'value': 2017},
{'name': 'tesla', 'value': 2017},
{'name': 'nissan', 'value': 2017},
]
package.get_resource('cars-2018').read(keyed=True) == [
{'name': 'bmw', 'value': 2018},
{'name': 'tesla', 'value': 2018},
{'name': 'nissan', 'value': 2018},
]
```
On the other hand, these resources defined with a `group: cars` field. It means we can treat them as a group:
```python
package = Package('datapackage.json')
package.get_group('cars').read(keyed=True) == [
{'name': 'bmw', 'value': 2017},
{'name': 'tesla', 'value': 2017},
{'name': 'nissan', 'value': 2017},
{'name': 'bmw', 'value': 2018},
{'name': 'tesla', 'value': 2018},
{'name': 'nissan', 'value': 2018},
]
```
We can use this approach when we need to save the data package to a storage, for example, to a SQL database. There is the `merge_groups` flag to enable groupping behaviour:
```python
package = Package('datapackage.json')
package.save(storage='sql', engine=engine)
# SQL tables:
# - cars-2017
# - cars-2018
package.save(storage='sql', engine=engine, merge_groups=True)
# SQL tables:
# - cars
```
### Working with Profile
A component to represent JSON Schema profile from [Profiles Registry]( https://specs.frictionlessdata.io/schemas/registry.json):
```python
profile = Profile('data-package')
profile.name # data-package
profile.jsonschema # JSON Schema contents
try:
valid = profile.validate(descriptor)
except exceptions.ValidationError as exception:
for error in exception.errors:
# handle individual error
```
### Working with Foreign Keys
The library supports foreign keys described in the [Table Schema](http://specs.frictionlessdata.io/table-schema/#foreign-keys) specification. It means if your data package descriptor use `resources[].schema.foreignKeys` property for some resources a data integrity will be checked on reading operations.
Consider we have a data package:
```python
DESCRIPTOR = {
'resources': [
{
'name': 'teams',
'data': [
['id', 'name', 'city'],
['1', 'Arsenal', 'London'],
['2', 'Real', 'Madrid'],
['3', 'Bayern', 'Munich'],
],
'schema': {
'fields': [
{'name': 'id', 'type': 'integer'},
{'name': 'name', 'type': 'string'},
{'name': 'city', 'type': 'string'},
],
'foreignKeys': [
{
'fields': 'city',
'reference': {'resource': 'cities', 'fields': 'name'},
},
],
},
}, {
'name': 'cities',
'data': [
['name', 'country'],
['London', 'England'],
['Madrid', 'Spain'],
],
},
],
}
```
Let's check relations for a `teams` resource:
```python
from datapackage import Package
package = Package(DESCRIPTOR)
teams = package.get_resource('teams')
teams.check_relations()
# tableschema.exceptions.RelationError: Foreign key "['city']" violation in row "4"
```
As we could see there is a foreign key violation. That's because our lookup table `cities` doesn't have a city of `Munich` but we have a team from there. We need to fix it in `cities` resource:
```python
package.descriptor['resources'][1]['data'].append(['Munich', 'Germany'])
package.commit()
teams = package.get_resource('teams')
teams.check_relations()
# True
```
Fixed! But not only a check operation is available. We could use `relations` argument for `resource.iter/read` methods to dereference a resource relations:
```python
teams.read(keyed=True, relations=True)
#[{'id': 1, 'name': 'Arsenal', 'city': {'name': 'London', 'country': 'England}},
# {'id': 2, 'name': 'Real', 'city': {'name': 'Madrid', 'country': 'Spain}},
# {'id': 3, 'name': 'Bayern', 'city': {'name': 'Munich', 'country': 'Germany}}]
```
Instead of plain city name we've got a dictionary containing a city data. These `resource.iter/read` methods will fail with the same as `resource.check_relations` error if there is an integrity issue. But only if `relations=True` flag is passed.
### Working with validate/infer
A standalone function to validate a data package descriptor:
```python
from datapackage import validate, exceptions
try:
valid = validate(descriptor)
except exceptions.ValidationError as exception:
for error in exception.errors:
# handle individual error
```
A standalone function to infer a data package descriptor.
```python
descriptor = infer('**/*.csv')
#{ profile: 'tabular-data-resource',
# resources:
# [ { path: 'data/cities.csv',
# profile: 'tabular-data-resource',
# encoding: 'utf-8',
# name: 'cities',
# format: 'csv',
# mediatype: 'text/csv',
# schema: [Object] },
# { path: 'data/population.csv',
# profile: 'tabular-data-resource',
# encoding: 'utf-8',
# name: 'population',
# format: 'csv',
# mediatype: 'text/csv',
# schema: [Object] } ] }
```
### Frequently Asked Questions
#### Accessing data behind a proxy server?
Before the `package = Package("https://xxx.json")` call set these environment variables:
```python
import os
os.environ["HTTP_PROXY"] = 'xxx'
os.environ["HTTPS_PROXY"] = 'xxx'
```
## API Reference
### `cli`
```python
cli()
```
Command-line interface
```
Usage: datapackage [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
infer
validate
```
### `Package`
```python
Package(self,
descriptor=None,
base_path=None,
strict=False,
unsafe=False,
storage=None,
schema=None,
default_base_path=None,
**options)
```
Package representation
__Arguments__
- __descriptor (str/dict)__: data package descriptor as local path, url or object
- __base_path (str)__: base path for all relative paths
- __strict (bool)__: strict flag to alter validation behavior.
Setting it to `True` leads to throwing errors
on any operation with invalid descriptor
- __unsafe (bool)__:
if `True` unsafe paths will be allowed. For more inforamtion
https://specs.frictionlessdata.io/data-resource/#data-location.
Default to `False`
- __storage (str/tableschema.Storage)__: storage name like `sql` or storage instance
- __options (dict)__: storage options to use for storage creation
__Raises__
- `DataPackageException`: raises error if something goes wrong
#### `package.base_path`
Package's base path
__Returns__
`str/None`: returns the data package base path
#### `package.descriptor`
Package's descriptor
__Returns__
`dict`: descriptor
#### `package.errors`
Validation errors
Always empty in strict mode.
__Returns__
`Exception[]`: validation errors
#### `package.profile`
Package's profile
__Returns__
`Profile`: an instance of `Profile` class
#### `package.resource_names`
Package's resource names
__Returns__
`str[]`: returns an array of resource names
#### `package.resources`
Package's resources
__Returns__
`Resource[]`: returns an array of `Resource` instances
#### `package.valid`
Validation status
Always true in strict mode.
__Returns__
`bool`: validation status
#### `package.get_resource`
```python
package.get_resource(name)
```
Get data package resource by name.
__Arguments__
- __name (str)__: data resource name
__Returns__
`Resource/None`: returns `Resource` instances or null if not found
#### `package.add_resource`
```python
package.add_resource(descriptor)
```
Add new resource to data package.
The data package descriptor will be validated with newly added resource descriptor.
__Arguments__
- __descriptor (dict)__: data resource descriptor
__Raises__
- `DataPackageException`: raises error if something goes wrong
__Returns__
`Resource/None`: returns added `Resource` instance or null if not added
#### `package.remove_resource`
```python
package.remove_resource(name)
```
Remove data package resource by name.
The data package descriptor will be validated after resource descriptor removal.
__Arguments__
- __name (str)__: data resource name
__Raises__
- `DataPackageException`: raises error if something goes wrong
__Returns__
`Resource/None`: returns removed `Resource` instances or null if not found
#### `package.get_group`
```python
package.get_group(name)
```
Returns a group of tabular resources by name.
For more information about groups see [Group](#group).
__Arguments__
- __name (str)__: name of a group of resources
__Raises__
- `DataPackageException`: raises error if something goes wrong
__Returns__
`Group/None`: returns a `Group` instance or null if not found
#### `package.infer`
```python
package.infer(pattern=False)
```
Infer a data package metadata.
> Argument `pattern` works only for local files
If `pattern` is not provided only existent resources will be inferred
(added metadata like encoding, profile etc). If `pattern` is provided
new resoures with file names mathing the pattern will be added and inferred.
It commits changes to data package instance.
__Arguments__
- __pattern (str)__: glob pattern for new resources
__Returns__
`dict`: returns data package descriptor
#### `package.commit`
```python
package.commit(strict=None)
```
Update data package instance if there are in-place changes in the descriptor.
__Example__
```python
package = Package({
'name': 'package',
'resources': [{'name': 'resource', 'data': ['data']}]
})
package.name # package
package.descriptor['name'] = 'renamed-package'
package.name # package
package.commit()
package.name # renamed-package
```
__Arguments__
- __strict (bool)__: alter `strict` mode for further work
__Raises__
- `DataPackageException`: raises error if something goes wrong
__Returns__
`bool`: returns true on success and false if not modified
#### `package.save`
```python
package.save(target=None,
storage=None,
merge_groups=False,
to_base_path=False,
**options)
```
Saves this data package
It saves it to storage if `storage` argument is passed or
saves this data package's descriptor to json file if `target` arguments
ends with `.json` or saves this data package to zip file otherwise.
__Example__
It creates a zip file into ``file_or_path`` with the contents
of this Data Package and its resources. Every resource which content
lives in the local filesystem will be copied to the zip file.
Consider the following Data Package descriptor:
```json
{
"name": "gdp",
"resources": [
{"name": "local", "format": "CSV", "path": "data.csv"},
{"name": "inline", "data": [4, 8, 15, 16, 23, 42]},
{"name": "remote", "url": "http://someplace.com/data.csv"}
]
}
```
The final structure of the zip file will be:
```
./datapackage.json
./data/local.csv
```
With the contents of `datapackage.json` being the same as
returned `datapackage.descriptor`. The resources' file names are generated
based on their `name` and `format` fields if they exist.
If the resource has no `name`, it'll be used `resource-X`,
where `X` is the index of the resource in the `resources` list (starting at zero).
If the resource has `format`, it'll be lowercased and appended to the `name`,
becoming "`name.format`".
__Arguments__
- __target (string/filelike)__:
the file path or a file-like object where
the contents of this Data Package will be saved into.
- __storage (str/tableschema.Storage)__:
storage name like `sql` or storage instance
- __merge_groups (bool)__:
save all the group's tabular resoruces into one bucket
if a storage is provided (for example into one SQL table).
Read more about [Group](#group).
- __to_base_path (bool)__:
save the package to the package's base path
using the "<base_path>/<target>" route
- __options (dict)__:
storage options to use for storage creation
__Raises__
- `DataPackageException`: raises if there was some error writing the package
__Returns__
`bool/Storage`: on success return true or a `Storage` instance
### `Resource`
```python
Resource(self,
descriptor={},
base_path=None,
strict=False,
unsafe=False,
storage=None,
package=None,
**options)
```
Resource represenation
__Arguments__
- __descriptor (str/dict)__: data resource descriptor as local path, url or object
- __base_path (str)__: base path for all relative paths
- __strict (bool)__:
strict flag to alter validation behavior. Setting it to `true`
leads to throwing errors on any operation with invalid descriptor
- __unsafe (bool)__:
if `True` unsafe paths will be allowed. For more inforamtion
https://specs.frictionlessdata.io/data-resource/#data-location.
Default to `False`
- __storage (str/tableschema.Storage)__: storage name like `sql` or storage instance
- __options (dict)__: storage options to use for storage creation
__Raises__
- `DataPackageException`: raises error if something goes wrong
#### `resource.data`
Return resource data
#### `resource.descriptor`
Package's descriptor
__Returns__
`dict`: descriptor
#### `resource.errors`
Validation errors
Always empty in strict mode.
__Returns__
`Exception[]`: validation errors
#### `resource.group`
Group name
__Returns__
`str`: group name
#### `resource.headers`
Resource's headers
> Only for tabular resources (reading has to be started first or it's `None`)
__Returns__
`str[]/None`: returns data source headers
#### `resource.inline`
Whether resource inline
__Returns__
`bool`: returns true if resource is inline
#### `resource.local`
Whether resource local
__Returns__
`bool`: returns true if resource is local
#### `resource.multipart`
Whether resource multipart
__Returns__
`bool`: returns true if resource is multipart
#### `resource.name`
Resource name
__Returns__
`str`: name
#### `resource.package`
Package instance if the resource belongs to some package
__Returns__
`Package/None`: a package instance if available
#### `resource.profile`
Resource's profile
__Returns__
`Profile`: an instance of `Profile` class
#### `resource.remote`
Whether resource remote
__Returns__
`bool`: returns true if resource is remote
#### `resource.schema`
Resource's schema
> Only for tabular resources
For tabular resources it returns `Schema` instance to interact with data schema.
Read API documentation - [tableschema.Schema](https://github.com/frictionlessdata/tableschema-py#schema).
__Returns__
`tableschema.Schema`: schema
#### `resource.source`
Resource's source
Combination of `resource.source` and `resource.inline/local/remote/multipart`
provides predictable interface to work with resource data.
__Returns__
`list/str`: returns `data` or `path` property
#### `resource.table`
Return resource table
#### `resource.tabular`
Whether resource tabular
__Returns__
`bool`: returns true if resource is tabular
#### `resource.valid`
Validation status
Always true in strict mode.
__Returns__
`bool`: validation status
#### `resource.iter`
```python
resource.iter(integrity=False, relations=False, **options)
```
Iterates through the resource data and emits rows cast based on table schema.
> Only for tabular resources
__Arguments__
keyed (bool):
yield keyed rows in a form of `{header1: value1, header2: value2}`
(default is false; the form of rows is `[value1, value2]`)
extended (bool):
yield extended rows in a for of `[rowNumber, [header1, header2], [value1, value2]]`
(default is false; the form of rows is `[value1, value2]`)
cast (bool):
disable data casting if false
(default is true)
integrity (bool):
if true actual size in BYTES and SHA256 hash of the file
will be checked against `descriptor.bytes` and `descriptor.hash`
(other hashing algorithms are not supported and will be skipped silently)
relations (bool):
if true foreign key fields will be checked and resolved to its references
foreign_keys_values (dict):
three-level dictionary of foreign key references optimized
to speed up validation process in a form of
`{resource1: {(fk_field1, fk_field2): {(value1, value2): {one_keyedrow}, ... }}}`.
If not provided but relations is true, it will be created
before the validation process by *index_foreign_keys_values* method
exc_handler (func):
optional custom exception handler callable.
Can be used to defer raising errors (i.e. "fail late"), e.g.
for data validation purposes. Must support the signature below
__Custom exception handler__
```python
def exc_handler(exc, row_number=None, row_data=None, error_data=None):
'''Custom exception handler (example)
# Arguments:
exc(Exception):
Deferred exception instance
row_number(int):
Data row number that triggers exception exc
row_data(OrderedDict):
Invalid data row source data
error_data(OrderedDict):
Data row source data field subset responsible for the error, if
applicable (e.g. invalid primary or foreign key fields). May be
identical to row_data.
'''
# ...
```
__Raises__
- `DataPackageException`: base class of any error
- `CastError`: data cast error
- `IntegrityError`: integrity checking error
- `UniqueKeyError`: unique key constraint violation
- `UnresolvedFKError`: unresolved foreign key reference error
__Returns__
`Iterator[list]`: yields rows
#### `resource.read`
```python
resource.read(integrity=False,
relations=False,
foreign_keys_values=False,
**options)
```
Read the whole resource and return as array of rows
> Only for tabular resources
> It has the same API as `resource.iter` except for
__Arguments__
- __limit (int)__: limit count of rows to read and return
__Returns__
`list[]`: returns rows
#### `resource.check_integrity`
```python
resource.check_integrity()
```
Checks resource integrity
> Only for tabular resources
It checks size in BYTES and SHA256 hash of the file
against `descriptor.bytes` and `descriptor.hash`
(other hashing algorithms are not supported and will be skipped silently).
__Raises__
- `exceptions.IntegrityError`: raises if there are integrity issues
__Returns__
`bool`: returns True if no issues
#### `resource.check_relations`
```python
resource.check_relations(foreign_keys_values=False)
```
Check relations
> Only for tabular resources
It checks foreign keys and raises an exception if there are integrity issues.
__Raises__
- `exceptions.RelationError`: raises if there are relation issues
__Returns__
`bool`: returns True if no issues
#### `resource.drop_relations`
```python
resource.drop_relations()
```
Drop relations
> Only for tabular resources
Remove relations data from memory
__Returns__
`bool`: returns True
#### `resource.raw_iter`
```python
resource.raw_iter(stream=False)
```
Iterate over data chunks as bytes.
If `stream` is true File-like object will be returned.
__Arguments__
- __stream (bool)__: File-like object will be returned
__Returns__
`bytes[]/filelike`: returns bytes[]/filelike
#### `resource.raw_read`
```python
resource.raw_read()
```
Returns resource data as bytes.
__Returns__
`bytes`: returns resource data in bytes
#### `resource.infer`
```python
resource.infer(**options)
```
Infer resource metadata
Like name, format, mediatype, encoding, schema and profile.
It commits this changes into resource instance.
__Arguments__
- __options__:
options will be passed to `tableschema.infer` call,
for more control on results (e.g. for setting `limit`, `confidence` etc.).
__Returns__
`dict`: returns resource descriptor
#### `resource.commit`
```python
resource.commit(strict=None)
```
Update resource instance if there are in-place changes in the descriptor.
__Arguments__
- __strict (bool)__: alter `strict` mode for further work
__Raises__
- `DataPackageException`: raises error if something goes wrong
__Returns__
`bool`: returns true on success and false if not modified
#### `resource.save`
```python
resource.save(target, storage=None, to_base_path=False, **options)
```
Saves this resource
Into storage if `storage` argument is passed or
saves this resource's descriptor to json file otherwise.
__Arguments__
- __target (str)__:
path where to save a resource
- __storage (str/tableschema.Storage)__:
storage name like `sql` or storage instance
- __to_base_path (bool)__:
save the resource to the resource's base path
using the "<base_path>/<target>" route
- __options (dict)__:
storage options to use for storage creation
__Raises__
- `DataPackageException`: raises error if something goes wrong
__Returns__
`bool`: returns true on success
Building index...
Started generating documentation...
### `Group`
```python
Group(self, resources)
```
Group representation
__Arguments__
- __Resource[]__: list of TABULAR resources
#### `group.headers`
Group's headers
__Returns__
`str[]/None`: returns headers
#### `group.name`
Group name
__Returns__
`str`: name
#### `group.schema`
Resource's schema
__Returns__
`tableschema.Schema`: schema
#### `group.iter`
```python
group.iter(**options)
```
Iterates through the group data and emits rows cast based on table schema.
> It concatenates all the resources and has the same API as `resource.iter`
#### `group.read`
```python
group.read(limit=None, **options)
```
Read the whole group and return as array of rows
> It concatenates all the resources and has the same API as `resource.read`
#### `group.check_relations`
```python
group.check_relations()
```
Check group's relations
The same as `resource.check_relations` but without the optional
argument *foreign_keys_values*. This method will test foreignKeys of the
whole group at once otpimizing the process by creating the foreign_key_values
hashmap only once before testing the set of resources.
### `Profile`
```python
Profile(self, profile)
```
Profile representation
__Arguments__
- __profile (str)__: profile name in registry or URL to JSON Schema
__Raises__
- `DataPackageException`: raises error if something goes wrong
#### `profile.jsonschema`
JSONSchema content
__Returns__
`dict`: returns profile's JSON Schema contents
#### `profile.name`
Profile name
__Returns__
`str/None`: name if available
#### `profile.validate`
```python
profile.validate(descriptor)
```
Validate a data package `descriptor` against the profile.
__Arguments__
- __descriptor (dict)__: retrieved and dereferenced data package descriptor
__Raises__
- `ValidationError`: raises if not valid
__Returns__
`bool`: returns True if valid
### `validate`
```python
validate(descriptor)
```
Validate a data package descriptor.
__Arguments__
- __descriptor (str/dict)__: package descriptor (one of):
- local path
- remote url
- object
__Raises__
- `ValidationError`: raises on invalid
__Returns__
`bool`: returns true on valid
### `infer`
```python
infer(pattern, base_path=None)
```
Infer a data package descriptor.
> Argument `pattern` works only for local files
__Arguments__
- __pattern (str)__: glob file pattern
__Returns__
`dict`: returns data package descriptor
### `DataPackageException`
```python
DataPackageException(self, message, errors=[])
```
Base class for all DataPackage/TableSchema exceptions.
If there are multiple errors, they can be read from the exception object:
```python
try:
# lib action
except DataPackageException as exception:
if exception.multiple:
for error in exception.errors:
# handle error
```
#### `datapackageexception.errors`
List of nested errors
__Returns__
`DataPackageException[]`: list of nested errors
#### `datapackageexception.multiple`
Whether it's a nested exception
__Returns__
`bool`: whether it's a nested exception
### `TableSchemaException`
```python
TableSchemaException(self, message, errors=[])
```
Base class for all TableSchema exceptions.
### `LoadError`
```python
LoadError(self, message, errors=[])
```
All loading errors.
### `CastError`
```python
CastError(self, message, errors=[])
```
All value cast errors.
### `IntegrityError`
```python
IntegrityError(self, message, errors=[])
```
All integrity errors.
### `RelationError`
```python
RelationError(self, message, errors=[])
```
All relations errors.
### `StorageError`
```python
StorageError(self, message, errors=[])
```
All storage errors.
## Contributing
> The project follows the [Open Knowledge International coding standards](https://github.com/okfn/coding-standards).
Recommended way to get started is to create and activate a project virtual environment.
To install package and development dependencies into active environment:
```bash
$ make install
```
To run tests with linting and coverage:
```bash
$ make test
```
## Changelog
Here described only breaking and the most important changes. The full changelog and documentation for all released versions could be found in nicely formatted [commit history](https://github.com/frictionlessdata/datapackage-py/commits/master).
#### v1.15
> WARNING: it can be breaking for some setups, please read the discussions below
- Fixed header management according to the specs:
- https://github.com/frictionlessdata/datapackage-py/pull/257
- https://github.com/frictionlessdata/datapackage-py/issues/256
- https://github.com/frictionlessdata/forum/issues/1
#### v1.14
- Add experimental options for pick/skiping fileds/rows
#### v1.13
- Add `unsafe` option to Package and Resource (#262)
#### v1.12
- Use `chardet` for encoding deteciton by default. For `cchardet`: `pip install datapackage[cchardet]`
#### v1.11
- `resource/package.save` now accept a `to_base_path` argument (#254)
- `package.save` now returns a `Storage` instance if available
#### v1.10
- Added an ability to check tabular resource's integrity
#### v1.9
- Added `resource.package` property
#### v1.8
- Added support for [groups of resources](#group)
#### v1.7
- Added support for [compression of resources](https://frictionlessdata.io/specs/patterns/#compression-of-resources)
#### v1.6
- Added support for custom request session
#### v1.5
Updated behaviour:
- Added support for Python 3.7
#### v1.4
New API added:
- added `skip_rows` support to the resource descriptor
#### v1.3
New API added:
- property `package.base_path` is now publicly available
#### v1.2
Updated behaviour:
- CLI command `$ datapackage infer` now outputs only a JSON-formatted data package descriptor.
#### v1.1
New API added:
- Added an integration between `Package/Resource` and the `tableschema.Storage` - https://github.com/frictionlessdata/tableschema-py#storage. It allows to load and save data package from/to different storages like SQL/BigQuery/etc.
Raw data
{
"_id": null,
"home_page": "https://github.com/frictionlessdata/datapackage-py",
"name": "datapackage",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "frictionless data,open data,json schema,table schema,data package,tabular data package",
"author": "Open Knowledge Foundation",
"author_email": "info@okfn.org",
"download_url": "https://files.pythonhosted.org/packages/c7/83/ef759d618745503e66c33aa9e218a954c3637a1b9a700ac9b368b5c9908b/datapackage-1.15.2.tar.gz",
"platform": "",
"description": "# datapackage-py\n\n[![Travis](https://travis-ci.org/frictionlessdata/datapackage-py.svg?branch=master)](https://travis-ci.org/frictionlessdata/datapackage-py)\n[![Coveralls](https://coveralls.io/repos/github/frictionlessdata/datapackage-py/badge.svg?branch=master)](https://coveralls.io/github/frictionlessdata/datapackage-py?branch=master)\n[![PyPi](https://img.shields.io/pypi/v/datapackage.svg)](https://pypi.python.org/pypi/datapackage)\n[![Github](https://img.shields.io/badge/github-master-brightgreen)](https://github.com/frictionlessdata/datapackage-py)\n[![Gitter](https://img.shields.io/gitter/room/frictionlessdata/chat.svg)](https://gitter.im/frictionlessdata/chat)\n\nA library for working with [Data Packages](http://specs.frictionlessdata.io/data-package/).\n\n> **[Important Notice]** We have released [Frictionless Framework](https://github.com/frictionlessdata/frictionless-py). This framework provides improved `datapackage` functionality extended to be a complete data solution. The change in not breaking for the existing software so no actions are required. Please read the [Migration Guide](https://framework.frictionlessdata.io/docs/development/migration) from `datapackage` to Frictionless Framework.\n> - we continue to bug-fix `datapackage@1.x` in this [repository](https://github.com/frictionlessdata/datapackage-py) as well as it's available on [PyPi](https://pypi.org/project/datapackage/) as it was before\n> - please note that `frictionless@3.x` version's API, we're working on at the moment, is not stable\n> - we will release `frictionless@4.x` by the end of 2020 to be the first SemVer/stable version\n\n## Features\n\n - `Package` class for working with data packages\n - `Resource` class for working with data resources\n - `Profile` class for working with profiles\n - `validate` function for validating data package descriptors\n - `infer` function for inferring data package descriptors\n\n## Contents\n\n<!--TOC-->\n\n - [Getting Started](#getting-started)\n - [Installation](#installation)\n - [Documentation](#documentation)\n - [Introduction](#introduction)\n - [Working with Package](#working-with-package)\n - [Working with Resource](#working-with-resource)\n - [Working with Group](#working-with-group)\n - [Working with Profile](#working-with-profile)\n - [Working with Foreign Keys](#working-with-foreign-keys)\n - [Working with validate/infer](#working-with-validateinfer)\n - [Frequently Asked Questions](#frequently-asked-questions)\n - [API Reference](#api-reference)\n - [`cli`](#cli)\n - [`Package`](#package)\n - [`Resource`](#resource)\n - [`Group`](#group)\n - [`Profile`](#profile)\n - [`validate`](#validate)\n - [`infer`](#infer)\n - [`DataPackageException`](#datapackageexception)\n - [`TableSchemaException`](#tableschemaexception)\n - [`LoadError`](#loaderror)\n - [`CastError`](#casterror)\n - [`IntegrityError`](#integrityerror)\n - [`RelationError`](#relationerror)\n - [`StorageError`](#storageerror)\n - [Contributing](#contributing)\n - [Changelog](#changelog)\n\n<!--TOC-->\n\n## Getting Started\n\n### Installation\n\nThe package use semantic versioning. It means that major versions could include breaking changes. It's highly recommended to specify `datapackage` version range in your `setup/requirements` file e.g. `datapackage>=1.0,<2.0`.\n\n```bash\n$ pip install datapackage\n```\n\n#### OSX 10.14+\nIf you receive an error about the `cchardet` package when installing datapackage on Mac OSX 10.14 (Mojave) or higher, follow these steps:\n1. Make sure you have the latest x-code by running the following in terminal: `xcode-select --install`\n2. Then go to [https://developer.apple.com/download/more/](https://developer.apple.com/download/more/) and download the `command line tools`. Note, this requires an Apple ID.\n3. Then, in terminal, run `open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg`\nYou can read more about these steps in this [post.](https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave)\n\n## Documentation\n\n### Introduction\n\nLet's start with a simple example:\n\n```python\nfrom datapackage import Package\n\npackage = Package('datapackage.json')\npackage.get_resource('resource').read()\n```\n\n### Working with Package\n\nA class for working with data packages. It provides various capabilities like loading local or remote data package, inferring a data package descriptor, saving a data package descriptor and many more.\n\nConsider we have some local csv files in a `data` directory. Let's create a data package based on this data using a `Package` class:\n\n> data/cities.csv\n\n```csv\ncity,location\nlondon,\"51.50,-0.11\"\nparis,\"48.85,2.30\"\nrome,\"41.89,12.51\"\n```\n\n> data/population.csv\n\n```csv\ncity,year,population\nlondon,2017,8780000\nparis,2017,2240000\nrome,2017,2860000\n```\n\nFirst we create a blank data package:\n\n```python\npackage = Package()\n```\n\nNow we're ready to infer a data package descriptor based on data files we have. Because we have two csv files we use glob pattern `**/*.csv`:\n\n```python\npackage.infer('**/*.csv')\npackage.descriptor\n#{ profile: 'tabular-data-package',\n# resources:\n# [ { path: 'data/cities.csv',\n# profile: 'tabular-data-resource',\n# encoding: 'utf-8',\n# name: 'cities',\n# format: 'csv',\n# mediatype: 'text/csv',\n# schema: [Object] },\n# { path: 'data/population.csv',\n# profile: 'tabular-data-resource',\n# encoding: 'utf-8',\n# name: 'population',\n# format: 'csv',\n# mediatype: 'text/csv',\n# schema: [Object] } ] }\n```\n\nAn `infer` method has found all our files and inspected it to extract useful metadata like profile, encoding, format, Table Schema etc. Let's tweak it a little bit:\n\n```python\npackage.descriptor['resources'][1]['schema']['fields'][1]['type'] = 'year'\npackage.commit()\npackage.valid # true\n```\n\nBecause our resources are tabular we could read it as a tabular data:\n\n```python\npackage.get_resource('population').read(keyed=True)\n#[ { city: 'london', year: 2017, population: 8780000 },\n# { city: 'paris', year: 2017, population: 2240000 },\n# { city: 'rome', year: 2017, population: 2860000 } ]\n```\n\nLet's save our descriptor on the disk as a zip-file:\n\n```python\npackage.save('datapackage.zip')\n```\n\nTo continue the work with the data package we just load it again but this time using local `datapackage.zip`:\n\n```python\npackage = Package('datapackage.zip')\n# Continue the work\n```\n\nIt was onle basic introduction to the `Package` class. To learn more let's take a look on `Package` class API reference.\n\n### Working with Resource\n\nA class for working with data resources. You can read or iterate tabular resources using the `iter/read` methods and all resource as bytes using `row_iter/row_read` methods.\n\nConsider we have some local csv file. It could be inline data or remote link - all supported by `Resource` class (except local files for in-brower usage of course). But say it's `data.csv` for now:\n\n```csv\ncity,location\nlondon,\"51.50,-0.11\"\nparis,\"48.85,2.30\"\nrome,N/A\n```\n\nLet's create and read a resource. Because resource is tabular we could use `resource.read` method with a `keyed` option to get an array of keyed rows:\n\n```python\nresource = Resource({path: 'data.csv'})\nresource.tabular # true\nresource.read(keyed=True)\n# [\n# {city: 'london', location: '51.50,-0.11'},\n# {city: 'paris', location: '48.85,2.30'},\n# {city: 'rome', location: 'N/A'},\n# ]\nresource.headers\n# ['city', 'location']\n# (reading has to be started first)\n```\n\nAs we could see our locations are just a strings. But it should be geopoints. Also Rome's location is not available but it's also just a `N/A` string instead of Python `None`. First we have to infer resource metadata:\n\n```python\nresource.infer()\nresource.descriptor\n#{ path: 'data.csv',\n# profile: 'tabular-data-resource',\n# encoding: 'utf-8',\n# name: 'data',\n# format: 'csv',\n# mediatype: 'text/csv',\n# schema: { fields: [ [Object], [Object] ], missingValues: [ '' ] } }\nresource.read(keyed=True)\n# Fails with a data validation error\n```\n\nLet's fix not available location. There is a `missingValues` property in Table Schema specification. As a first try we set `missingValues` to `N/A` in `resource.descriptor.schema`. Resource descriptor could be changed in-place but all changes should be commited by `resource.commit()`:\n\n```python\nresource.descriptor['schema']['missingValues'] = 'N/A'\nresource.commit()\nresource.valid # False\nresource.errors\n# [<ValidationError: \"'N/A' is not of type 'array'\">]\n```\n\nAs a good citiziens we've decided to check out recource descriptor validity. And it's not valid! We should use an array for `missingValues` property. Also don't forget to have an empty string as a missing value:\n\n```python\nresource.descriptor['schema']['missingValues'] = ['', 'N/A']\nresource.commit()\nresource.valid # true\n```\n\nAll good. It looks like we're ready to read our data again:\n\n```python\nresource.read(keyed=True)\n# [\n# {city: 'london', location: [51.50,-0.11]},\n# {city: 'paris', location: [48.85,2.30]},\n# {city: 'rome', location: null},\n# ]\n```\n\nNow we see that:\n- locations are arrays with numeric lattide and longitude\n- Rome's location is a native JavaScript `null`\n\nAnd because there are no errors on data reading we could be sure that our data is valid againt our schema. Let's save our resource descriptor:\n\n```python\nresource.save('dataresource.json')\n```\n\nLet's check newly-crated `dataresource.json`. It contains path to our data file, inferred metadata and our `missingValues` tweak:\n\n```json\n{\n \"path\": \"data.csv\",\n \"profile\": \"tabular-data-resource\",\n \"encoding\": \"utf-8\",\n \"name\": \"data\",\n \"format\": \"csv\",\n \"mediatype\": \"text/csv\",\n \"schema\": {\n \"fields\": [\n {\n \"name\": \"city\",\n \"type\": \"string\",\n \"format\": \"default\"\n },\n {\n \"name\": \"location\",\n \"type\": \"geopoint\",\n \"format\": \"default\"\n }\n ],\n \"missingValues\": [\n \"\",\n \"N/A\"\n ]\n }\n}\n```\n\nIf we decide to improve it even more we could update the `dataresource.json` file and then open it again using local file name:\n\n```python\nresource = Resource('dataresource.json')\n# Continue the work\n```\n\nIt was onle basic introduction to the `Resource` class. To learn more let's take a look on `Resource` class API reference.\n\n### Working with Group\n\nA class representing a group of tabular resources. Groups can be used to read multiple resource as one or to export them, for example, to a database as one table. To define a group add the `group: <name>` field to corresponding resources. The group's metadata will be created from the \"leading\" resource's metadata (the first resource with the group name).\n\nConsider we have a data package with two tables partitioned by a year and a shared schema stored separately:\n\n> cars-2017.csv\n\n```csv\nname,value\nbmw,2017\ntesla,2017\nnissan,2017\n```\n\n> cars-2018.csv\n\n```csv\nname,value\nbmw,2018\ntesla,2018\nnissan,2018\n```\n\n> cars.schema.json\n\n```json\n{\n \"fields\": [\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"value\",\n \"type\": \"integer\"\n }\n ]\n}\n```\n\n> datapackage.json\n\n```json\n{\n \"name\": \"datapackage\",\n \"resources\": [\n {\n \"group\": \"cars\",\n \"name\": \"cars-2017\",\n \"path\": \"cars-2017.csv\",\n \"profile\": \"tabular-data-resource\",\n \"schema\": \"cars.schema.json\"\n },\n {\n \"group\": \"cars\",\n \"name\": \"cars-2018\",\n \"path\": \"cars-2018.csv\",\n \"profile\": \"tabular-data-resource\",\n \"schema\": \"cars.schema.json\"\n }\n ]\n}\n```\n\nLet's read the resources separately:\n\n```python\npackage = Package('datapackage.json')\npackage.get_resource('cars-2017').read(keyed=True) == [\n {'name': 'bmw', 'value': 2017},\n {'name': 'tesla', 'value': 2017},\n {'name': 'nissan', 'value': 2017},\n]\npackage.get_resource('cars-2018').read(keyed=True) == [\n {'name': 'bmw', 'value': 2018},\n {'name': 'tesla', 'value': 2018},\n {'name': 'nissan', 'value': 2018},\n]\n```\n\nOn the other hand, these resources defined with a `group: cars` field. It means we can treat them as a group:\n\n```python\npackage = Package('datapackage.json')\npackage.get_group('cars').read(keyed=True) == [\n {'name': 'bmw', 'value': 2017},\n {'name': 'tesla', 'value': 2017},\n {'name': 'nissan', 'value': 2017},\n {'name': 'bmw', 'value': 2018},\n {'name': 'tesla', 'value': 2018},\n {'name': 'nissan', 'value': 2018},\n]\n```\n\nWe can use this approach when we need to save the data package to a storage, for example, to a SQL database. There is the `merge_groups` flag to enable groupping behaviour:\n\n```python\npackage = Package('datapackage.json')\npackage.save(storage='sql', engine=engine)\n# SQL tables:\n# - cars-2017\n# - cars-2018\npackage.save(storage='sql', engine=engine, merge_groups=True)\n# SQL tables:\n# - cars\n```\n\n### Working with Profile\n\nA component to represent JSON Schema profile from [Profiles Registry]( https://specs.frictionlessdata.io/schemas/registry.json):\n\n```python\nprofile = Profile('data-package')\n\nprofile.name # data-package\nprofile.jsonschema # JSON Schema contents\n\ntry:\n valid = profile.validate(descriptor)\nexcept exceptions.ValidationError as exception:\n for error in exception.errors:\n # handle individual error\n```\n\n### Working with Foreign Keys\n\nThe library supports foreign keys described in the [Table Schema](http://specs.frictionlessdata.io/table-schema/#foreign-keys) specification. It means if your data package descriptor use `resources[].schema.foreignKeys` property for some resources a data integrity will be checked on reading operations.\n\nConsider we have a data package:\n\n```python\nDESCRIPTOR = {\n 'resources': [\n {\n 'name': 'teams',\n 'data': [\n ['id', 'name', 'city'],\n ['1', 'Arsenal', 'London'],\n ['2', 'Real', 'Madrid'],\n ['3', 'Bayern', 'Munich'],\n ],\n 'schema': {\n 'fields': [\n {'name': 'id', 'type': 'integer'},\n {'name': 'name', 'type': 'string'},\n {'name': 'city', 'type': 'string'},\n ],\n 'foreignKeys': [\n {\n 'fields': 'city',\n 'reference': {'resource': 'cities', 'fields': 'name'},\n },\n ],\n },\n }, {\n 'name': 'cities',\n 'data': [\n ['name', 'country'],\n ['London', 'England'],\n ['Madrid', 'Spain'],\n ],\n },\n ],\n}\n```\n\nLet's check relations for a `teams` resource:\n\n```python\nfrom datapackage import Package\n\npackage = Package(DESCRIPTOR)\nteams = package.get_resource('teams')\nteams.check_relations()\n# tableschema.exceptions.RelationError: Foreign key \"['city']\" violation in row \"4\"\n```\n\nAs we could see there is a foreign key violation. That's because our lookup table `cities` doesn't have a city of `Munich` but we have a team from there. We need to fix it in `cities` resource:\n\n```python\npackage.descriptor['resources'][1]['data'].append(['Munich', 'Germany'])\npackage.commit()\nteams = package.get_resource('teams')\nteams.check_relations()\n# True\n```\n\nFixed! But not only a check operation is available. We could use `relations` argument for `resource.iter/read` methods to dereference a resource relations:\n\n```python\nteams.read(keyed=True, relations=True)\n#[{'id': 1, 'name': 'Arsenal', 'city': {'name': 'London', 'country': 'England}},\n# {'id': 2, 'name': 'Real', 'city': {'name': 'Madrid', 'country': 'Spain}},\n# {'id': 3, 'name': 'Bayern', 'city': {'name': 'Munich', 'country': 'Germany}}]\n```\n\nInstead of plain city name we've got a dictionary containing a city data. These `resource.iter/read` methods will fail with the same as `resource.check_relations` error if there is an integrity issue. But only if `relations=True` flag is passed.\n\n### Working with validate/infer\n\nA standalone function to validate a data package descriptor:\n\n```python\nfrom datapackage import validate, exceptions\n\ntry:\n valid = validate(descriptor)\nexcept exceptions.ValidationError as exception:\n for error in exception.errors:\n # handle individual error\n```\n\nA standalone function to infer a data package descriptor.\n\n```python\ndescriptor = infer('**/*.csv')\n#{ profile: 'tabular-data-resource',\n# resources:\n# [ { path: 'data/cities.csv',\n# profile: 'tabular-data-resource',\n# encoding: 'utf-8',\n# name: 'cities',\n# format: 'csv',\n# mediatype: 'text/csv',\n# schema: [Object] },\n# { path: 'data/population.csv',\n# profile: 'tabular-data-resource',\n# encoding: 'utf-8',\n# name: 'population',\n# format: 'csv',\n# mediatype: 'text/csv',\n# schema: [Object] } ] }\n```\n\n### Frequently Asked Questions\n\n#### Accessing data behind a proxy server?\n\nBefore the `package = Package(\"https://xxx.json\")` call set these environment variables:\n\n```python\nimport os\n\nos.environ[\"HTTP_PROXY\"] = 'xxx'\nos.environ[\"HTTPS_PROXY\"] = 'xxx'\n```\n\n## API Reference\n\n### `cli`\n```python\ncli()\n```\nCommand-line interface\n\n```\nUsage: datapackage [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --version Show the version and exit.\n --help Show this message and exit.\n\nCommands:\n infer\n validate\n```\n\n\n### `Package`\n```python\nPackage(self,\n descriptor=None,\n base_path=None,\n strict=False,\n unsafe=False,\n storage=None,\n schema=None,\n default_base_path=None,\n **options)\n```\nPackage representation\n\n__Arguments__\n- __descriptor (str/dict)__: data package descriptor as local path, url or object\n- __base_path (str)__: base path for all relative paths\n- __strict (bool)__: strict flag to alter validation behavior.\n Setting it to `True` leads to throwing errors\n on any operation with invalid descriptor\n- __unsafe (bool)__:\n if `True` unsafe paths will be allowed. For more inforamtion\n https://specs.frictionlessdata.io/data-resource/#data-location.\n Default to `False`\n- __storage (str/tableschema.Storage)__: storage name like `sql` or storage instance\n- __options (dict)__: storage options to use for storage creation\n\n__Raises__\n- `DataPackageException`: raises error if something goes wrong\n\n\n\n#### `package.base_path`\nPackage's base path\n\n__Returns__\n\n`str/None`: returns the data package base path\n\n\n\n#### `package.descriptor`\nPackage's descriptor\n\n__Returns__\n\n`dict`: descriptor\n\n\n\n#### `package.errors`\nValidation errors\n\nAlways empty in strict mode.\n\n__Returns__\n\n`Exception[]`: validation errors\n\n\n\n#### `package.profile`\nPackage's profile\n\n__Returns__\n\n`Profile`: an instance of `Profile` class\n\n\n\n#### `package.resource_names`\nPackage's resource names\n\n__Returns__\n\n`str[]`: returns an array of resource names\n\n\n\n#### `package.resources`\nPackage's resources\n\n__Returns__\n\n`Resource[]`: returns an array of `Resource` instances\n\n\n\n#### `package.valid`\nValidation status\n\nAlways true in strict mode.\n\n__Returns__\n\n`bool`: validation status\n\n\n\n#### `package.get_resource`\n```python\npackage.get_resource(name)\n```\nGet data package resource by name.\n\n__Arguments__\n- __name (str)__: data resource name\n\n__Returns__\n\n`Resource/None`: returns `Resource` instances or null if not found\n\n\n\n#### `package.add_resource`\n```python\npackage.add_resource(descriptor)\n```\nAdd new resource to data package.\n\nThe data package descriptor will be validated with newly added resource descriptor.\n\n__Arguments__\n- __descriptor (dict)__: data resource descriptor\n\n__Raises__\n- `DataPackageException`: raises error if something goes wrong\n\n__Returns__\n\n`Resource/None`: returns added `Resource` instance or null if not added\n\n\n\n#### `package.remove_resource`\n```python\npackage.remove_resource(name)\n```\nRemove data package resource by name.\n\nThe data package descriptor will be validated after resource descriptor removal.\n\n__Arguments__\n- __name (str)__: data resource name\n\n__Raises__\n- `DataPackageException`: raises error if something goes wrong\n\n__Returns__\n\n`Resource/None`: returns removed `Resource` instances or null if not found\n\n\n\n#### `package.get_group`\n```python\npackage.get_group(name)\n```\nReturns a group of tabular resources by name.\n\nFor more information about groups see [Group](#group).\n\n__Arguments__\n- __name (str)__: name of a group of resources\n\n__Raises__\n- `DataPackageException`: raises error if something goes wrong\n\n__Returns__\n\n`Group/None`: returns a `Group` instance or null if not found\n\n\n\n#### `package.infer`\n```python\npackage.infer(pattern=False)\n```\nInfer a data package metadata.\n\n> Argument `pattern` works only for local files\n\nIf `pattern` is not provided only existent resources will be inferred\n(added metadata like encoding, profile etc). If `pattern` is provided\nnew resoures with file names mathing the pattern will be added and inferred.\nIt commits changes to data package instance.\n\n__Arguments__\n- __pattern (str)__: glob pattern for new resources\n\n__Returns__\n\n`dict`: returns data package descriptor\n\n\n\n#### `package.commit`\n```python\npackage.commit(strict=None)\n```\nUpdate data package instance if there are in-place changes in the descriptor.\n\n__Example__\n\n\n```python\npackage = Package({\n 'name': 'package',\n 'resources': [{'name': 'resource', 'data': ['data']}]\n})\n\npackage.name # package\npackage.descriptor['name'] = 'renamed-package'\npackage.name # package\npackage.commit()\npackage.name # renamed-package\n```\n\n__Arguments__\n- __strict (bool)__: alter `strict` mode for further work\n\n__Raises__\n- `DataPackageException`: raises error if something goes wrong\n\n__Returns__\n\n`bool`: returns true on success and false if not modified\n\n\n\n#### `package.save`\n```python\npackage.save(target=None,\n storage=None,\n merge_groups=False,\n to_base_path=False,\n **options)\n```\nSaves this data package\n\nIt saves it to storage if `storage` argument is passed or\nsaves this data package's descriptor to json file if `target` arguments\nends with `.json` or saves this data package to zip file otherwise.\n\n__Example__\n\n\nIt creates a zip file into ``file_or_path`` with the contents\nof this Data Package and its resources. Every resource which content\nlives in the local filesystem will be copied to the zip file.\nConsider the following Data Package descriptor:\n\n```json\n{\n \"name\": \"gdp\",\n \"resources\": [\n {\"name\": \"local\", \"format\": \"CSV\", \"path\": \"data.csv\"},\n {\"name\": \"inline\", \"data\": [4, 8, 15, 16, 23, 42]},\n {\"name\": \"remote\", \"url\": \"http://someplace.com/data.csv\"}\n ]\n}\n```\n\nThe final structure of the zip file will be:\n\n```\n./datapackage.json\n./data/local.csv\n```\n\nWith the contents of `datapackage.json` being the same as\nreturned `datapackage.descriptor`. The resources' file names are generated\nbased on their `name` and `format` fields if they exist.\nIf the resource has no `name`, it'll be used `resource-X`,\nwhere `X` is the index of the resource in the `resources` list (starting at zero).\nIf the resource has `format`, it'll be lowercased and appended to the `name`,\nbecoming \"`name.format`\".\n\n__Arguments__\n- __target (string/filelike)__:\n the file path or a file-like object where\n the contents of this Data Package will be saved into.\n- __storage (str/tableschema.Storage)__:\n storage name like `sql` or storage instance\n- __merge_groups (bool)__:\n save all the group's tabular resoruces into one bucket\n if a storage is provided (for example into one SQL table).\n Read more about [Group](#group).\n- __to_base_path (bool)__:\n save the package to the package's base path\n using the \"<base_path>/<target>\" route\n- __options (dict)__:\n storage options to use for storage creation\n\n__Raises__\n- `DataPackageException`: raises if there was some error writing the package\n\n__Returns__\n\n`bool/Storage`: on success return true or a `Storage` instance\n\n### `Resource`\n```python\nResource(self,\n descriptor={},\n base_path=None,\n strict=False,\n unsafe=False,\n storage=None,\n package=None,\n **options)\n```\nResource represenation\n\n__Arguments__\n- __descriptor (str/dict)__: data resource descriptor as local path, url or object\n- __base_path (str)__: base path for all relative paths\n- __strict (bool)__:\n strict flag to alter validation behavior. Setting it to `true`\n leads to throwing errors on any operation with invalid descriptor\n- __unsafe (bool)__:\n if `True` unsafe paths will be allowed. For more inforamtion\n https://specs.frictionlessdata.io/data-resource/#data-location.\n Default to `False`\n- __storage (str/tableschema.Storage)__: storage name like `sql` or storage instance\n- __options (dict)__: storage options to use for storage creation\n\n__Raises__\n- `DataPackageException`: raises error if something goes wrong\n\n\n\n#### `resource.data`\nReturn resource data\n\n\n#### `resource.descriptor`\nPackage's descriptor\n\n__Returns__\n\n`dict`: descriptor\n\n\n\n#### `resource.errors`\nValidation errors\n\nAlways empty in strict mode.\n\n__Returns__\n\n`Exception[]`: validation errors\n\n\n\n#### `resource.group`\nGroup name\n\n__Returns__\n\n`str`: group name\n\n\n\n#### `resource.headers`\nResource's headers\n\n> Only for tabular resources (reading has to be started first or it's `None`)\n\n__Returns__\n\n`str[]/None`: returns data source headers\n\n\n\n#### `resource.inline`\nWhether resource inline\n\n__Returns__\n\n`bool`: returns true if resource is inline\n\n\n\n#### `resource.local`\nWhether resource local\n\n__Returns__\n\n`bool`: returns true if resource is local\n\n\n\n#### `resource.multipart`\nWhether resource multipart\n\n__Returns__\n\n`bool`: returns true if resource is multipart\n\n\n\n#### `resource.name`\nResource name\n\n__Returns__\n\n`str`: name\n\n\n\n#### `resource.package`\nPackage instance if the resource belongs to some package\n\n__Returns__\n\n`Package/None`: a package instance if available\n\n\n\n#### `resource.profile`\nResource's profile\n\n__Returns__\n\n`Profile`: an instance of `Profile` class\n\n\n\n#### `resource.remote`\nWhether resource remote\n\n__Returns__\n\n`bool`: returns true if resource is remote\n\n\n\n#### `resource.schema`\nResource's schema\n\n> Only for tabular resources\n\nFor tabular resources it returns `Schema` instance to interact with data schema.\nRead API documentation - [tableschema.Schema](https://github.com/frictionlessdata/tableschema-py#schema).\n\n__Returns__\n\n`tableschema.Schema`: schema\n\n\n\n#### `resource.source`\nResource's source\n\nCombination of `resource.source` and `resource.inline/local/remote/multipart`\nprovides predictable interface to work with resource data.\n\n__Returns__\n\n`list/str`: returns `data` or `path` property\n\n\n\n#### `resource.table`\nReturn resource table\n\n\n#### `resource.tabular`\nWhether resource tabular\n\n__Returns__\n\n`bool`: returns true if resource is tabular\n\n\n\n#### `resource.valid`\nValidation status\n\nAlways true in strict mode.\n\n__Returns__\n\n`bool`: validation status\n\n\n\n#### `resource.iter`\n```python\nresource.iter(integrity=False, relations=False, **options)\n```\nIterates through the resource data and emits rows cast based on table schema.\n\n> Only for tabular resources\n\n__Arguments__\n\n\n keyed (bool):\n yield keyed rows in a form of `{header1: value1, header2: value2}`\n (default is false; the form of rows is `[value1, value2]`)\n\n extended (bool):\n yield extended rows in a for of `[rowNumber, [header1, header2], [value1, value2]]`\n (default is false; the form of rows is `[value1, value2]`)\n\n cast (bool):\n disable data casting if false\n (default is true)\n\n integrity (bool):\n if true actual size in BYTES and SHA256 hash of the file\n will be checked against `descriptor.bytes` and `descriptor.hash`\n (other hashing algorithms are not supported and will be skipped silently)\n\n relations (bool):\n if true foreign key fields will be checked and resolved to its references\n\n foreign_keys_values (dict):\n three-level dictionary of foreign key references optimized\n to speed up validation process in a form of\n `{resource1: {(fk_field1, fk_field2): {(value1, value2): {one_keyedrow}, ... }}}`.\n If not provided but relations is true, it will be created\n before the validation process by *index_foreign_keys_values* method\n\n exc_handler (func):\n optional custom exception handler callable.\n Can be used to defer raising errors (i.e. \"fail late\"), e.g.\n for data validation purposes. Must support the signature below\n\n__Custom exception handler__\n\n\n```python\ndef exc_handler(exc, row_number=None, row_data=None, error_data=None):\n '''Custom exception handler (example)\n\n # Arguments:\n exc(Exception):\n Deferred exception instance\n row_number(int):\n Data row number that triggers exception exc\n row_data(OrderedDict):\n Invalid data row source data\n error_data(OrderedDict):\n Data row source data field subset responsible for the error, if\n applicable (e.g. invalid primary or foreign key fields). May be\n identical to row_data.\n '''\n # ...\n```\n\n__Raises__\n- `DataPackageException`: base class of any error\n- `CastError`: data cast error\n- `IntegrityError`: integrity checking error\n- `UniqueKeyError`: unique key constraint violation\n- `UnresolvedFKError`: unresolved foreign key reference error\n\n__Returns__\n\n`Iterator[list]`: yields rows\n\n\n\n#### `resource.read`\n```python\nresource.read(integrity=False,\n relations=False,\n foreign_keys_values=False,\n **options)\n```\nRead the whole resource and return as array of rows\n\n> Only for tabular resources\n> It has the same API as `resource.iter` except for\n\n__Arguments__\n- __limit (int)__: limit count of rows to read and return\n\n__Returns__\n\n`list[]`: returns rows\n\n\n\n#### `resource.check_integrity`\n```python\nresource.check_integrity()\n```\nChecks resource integrity\n\n> Only for tabular resources\n\nIt checks size in BYTES and SHA256 hash of the file\nagainst `descriptor.bytes` and `descriptor.hash`\n(other hashing algorithms are not supported and will be skipped silently).\n\n__Raises__\n- `exceptions.IntegrityError`: raises if there are integrity issues\n\n__Returns__\n\n`bool`: returns True if no issues\n\n\n\n#### `resource.check_relations`\n```python\nresource.check_relations(foreign_keys_values=False)\n```\nCheck relations\n\n> Only for tabular resources\n\nIt checks foreign keys and raises an exception if there are integrity issues.\n\n__Raises__\n- `exceptions.RelationError`: raises if there are relation issues\n\n__Returns__\n\n`bool`: returns True if no issues\n\n\n\n#### `resource.drop_relations`\n```python\nresource.drop_relations()\n```\nDrop relations\n\n> Only for tabular resources\n\nRemove relations data from memory\n\n__Returns__\n\n`bool`: returns True\n\n\n\n#### `resource.raw_iter`\n```python\nresource.raw_iter(stream=False)\n```\nIterate over data chunks as bytes.\n\nIf `stream` is true File-like object will be returned.\n\n__Arguments__\n- __stream (bool)__: File-like object will be returned\n\n__Returns__\n\n`bytes[]/filelike`: returns bytes[]/filelike\n\n\n\n#### `resource.raw_read`\n```python\nresource.raw_read()\n```\nReturns resource data as bytes.\n\n__Returns__\n\n`bytes`: returns resource data in bytes\n\n\n\n#### `resource.infer`\n```python\nresource.infer(**options)\n```\nInfer resource metadata\n\nLike name, format, mediatype, encoding, schema and profile.\nIt commits this changes into resource instance.\n\n__Arguments__\n- __options__:\n options will be passed to `tableschema.infer` call,\n for more control on results (e.g. for setting `limit`, `confidence` etc.).\n\n__Returns__\n\n`dict`: returns resource descriptor\n\n\n\n#### `resource.commit`\n```python\nresource.commit(strict=None)\n```\nUpdate resource instance if there are in-place changes in the descriptor.\n\n__Arguments__\n- __strict (bool)__: alter `strict` mode for further work\n\n__Raises__\n- `DataPackageException`: raises error if something goes wrong\n\n__Returns__\n\n`bool`: returns true on success and false if not modified\n\n\n\n#### `resource.save`\n```python\nresource.save(target, storage=None, to_base_path=False, **options)\n```\nSaves this resource\n\nInto storage if `storage` argument is passed or\nsaves this resource's descriptor to json file otherwise.\n\n__Arguments__\n- __target (str)__:\n path where to save a resource\n- __storage (str/tableschema.Storage)__:\n storage name like `sql` or storage instance\n- __to_base_path (bool)__:\n save the resource to the resource's base path\n using the \"<base_path>/<target>\" route\n- __options (dict)__:\n storage options to use for storage creation\n\n__Raises__\n- `DataPackageException`: raises error if something goes wrong\n\n__Returns__\n\n`bool`: returns true on success\nBuilding index...\nStarted generating documentation...\n\n### `Group`\n```python\nGroup(self, resources)\n```\nGroup representation\n\n__Arguments__\n- __Resource[]__: list of TABULAR resources\n\n\n\n#### `group.headers`\nGroup's headers\n\n__Returns__\n\n`str[]/None`: returns headers\n\n\n\n#### `group.name`\nGroup name\n\n__Returns__\n\n`str`: name\n\n\n\n#### `group.schema`\nResource's schema\n\n__Returns__\n\n`tableschema.Schema`: schema\n\n\n\n#### `group.iter`\n```python\ngroup.iter(**options)\n```\nIterates through the group data and emits rows cast based on table schema.\n\n> It concatenates all the resources and has the same API as `resource.iter`\n\n\n\n#### `group.read`\n```python\ngroup.read(limit=None, **options)\n```\nRead the whole group and return as array of rows\n\n> It concatenates all the resources and has the same API as `resource.read`\n\n\n\n#### `group.check_relations`\n```python\ngroup.check_relations()\n```\nCheck group's relations\n\nThe same as `resource.check_relations` but without the optional\nargument *foreign_keys_values*. This method will test foreignKeys of the\nwhole group at once otpimizing the process by creating the foreign_key_values\nhashmap only once before testing the set of resources.\n\n\n### `Profile`\n```python\nProfile(self, profile)\n```\nProfile representation\n\n__Arguments__\n- __profile (str)__: profile name in registry or URL to JSON Schema\n\n__Raises__\n- `DataPackageException`: raises error if something goes wrong\n\n\n\n#### `profile.jsonschema`\nJSONSchema content\n\n__Returns__\n\n`dict`: returns profile's JSON Schema contents\n\n\n\n#### `profile.name`\nProfile name\n\n__Returns__\n\n`str/None`: name if available\n\n\n\n#### `profile.validate`\n```python\nprofile.validate(descriptor)\n```\nValidate a data package `descriptor` against the profile.\n\n__Arguments__\n- __descriptor (dict)__: retrieved and dereferenced data package descriptor\n\n__Raises__\n- `ValidationError`: raises if not valid\n__Returns__\n\n`bool`: returns True if valid\n\n\n### `validate`\n```python\nvalidate(descriptor)\n```\nValidate a data package descriptor.\n\n__Arguments__\n- __descriptor (str/dict)__: package descriptor (one of):\n - local path\n - remote url\n - object\n\n__Raises__\n- `ValidationError`: raises on invalid\n\n__Returns__\n\n`bool`: returns true on valid\n\n\n### `infer`\n```python\ninfer(pattern, base_path=None)\n```\nInfer a data package descriptor.\n\n> Argument `pattern` works only for local files\n\n__Arguments__\n- __pattern (str)__: glob file pattern\n\n__Returns__\n\n`dict`: returns data package descriptor\n\n\n### `DataPackageException`\n```python\nDataPackageException(self, message, errors=[])\n```\nBase class for all DataPackage/TableSchema exceptions.\n\nIf there are multiple errors, they can be read from the exception object:\n\n```python\ntry:\n # lib action\nexcept DataPackageException as exception:\n if exception.multiple:\n for error in exception.errors:\n # handle error\n```\n\n\n\n#### `datapackageexception.errors`\nList of nested errors\n\n__Returns__\n\n`DataPackageException[]`: list of nested errors\n\n\n\n#### `datapackageexception.multiple`\nWhether it's a nested exception\n\n__Returns__\n\n`bool`: whether it's a nested exception\n\n\n\n### `TableSchemaException`\n```python\nTableSchemaException(self, message, errors=[])\n```\nBase class for all TableSchema exceptions.\n\n\n### `LoadError`\n```python\nLoadError(self, message, errors=[])\n```\nAll loading errors.\n\n\n### `CastError`\n```python\nCastError(self, message, errors=[])\n```\nAll value cast errors.\n\n\n### `IntegrityError`\n```python\nIntegrityError(self, message, errors=[])\n```\nAll integrity errors.\n\n\n### `RelationError`\n```python\nRelationError(self, message, errors=[])\n```\nAll relations errors.\n\n\n### `StorageError`\n```python\nStorageError(self, message, errors=[])\n```\nAll storage errors.\n\n\n## Contributing\n\n> The project follows the [Open Knowledge International coding standards](https://github.com/okfn/coding-standards).\n\nRecommended way to get started is to create and activate a project virtual environment.\nTo install package and development dependencies into active environment:\n\n```bash\n$ make install\n```\n\nTo run tests with linting and coverage:\n\n```bash\n$ make test\n```\n\n## Changelog\n\nHere described only breaking and the most important changes. The full changelog and documentation for all released versions could be found in nicely formatted [commit history](https://github.com/frictionlessdata/datapackage-py/commits/master).\n\n#### v1.15\n\n> WARNING: it can be breaking for some setups, please read the discussions below\n\n- Fixed header management according to the specs:\n - https://github.com/frictionlessdata/datapackage-py/pull/257\n - https://github.com/frictionlessdata/datapackage-py/issues/256\n - https://github.com/frictionlessdata/forum/issues/1\n\n#### v1.14\n\n- Add experimental options for pick/skiping fileds/rows\n\n#### v1.13\n\n- Add `unsafe` option to Package and Resource (#262)\n\n#### v1.12\n\n- Use `chardet` for encoding deteciton by default. For `cchardet`: `pip install datapackage[cchardet]`\n\n#### v1.11\n\n- `resource/package.save` now accept a `to_base_path` argument (#254)\n- `package.save` now returns a `Storage` instance if available\n\n#### v1.10\n\n- Added an ability to check tabular resource's integrity\n\n#### v1.9\n\n- Added `resource.package` property\n\n#### v1.8\n\n- Added support for [groups of resources](#group)\n\n#### v1.7\n\n- Added support for [compression of resources](https://frictionlessdata.io/specs/patterns/#compression-of-resources)\n\n#### v1.6\n\n- Added support for custom request session\n\n#### v1.5\n\nUpdated behaviour:\n- Added support for Python 3.7\n\n#### v1.4\n\nNew API added:\n- added `skip_rows` support to the resource descriptor\n\n#### v1.3\n\nNew API added:\n- property `package.base_path` is now publicly available\n\n#### v1.2\n\nUpdated behaviour:\n- CLI command `$ datapackage infer` now outputs only a JSON-formatted data package descriptor.\n\n#### v1.1\n\nNew API added:\n- Added an integration between `Package/Resource` and the `tableschema.Storage` - https://github.com/frictionlessdata/tableschema-py#storage. It allows to load and save data package from/to different storages like SQL/BigQuery/etc.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Utilities to work with Data Packages as defined on specs.frictionlessdata.io",
"version": "1.15.2",
"split_keywords": [
"frictionless data",
"open data",
"json schema",
"table schema",
"data package",
"tabular data package"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "568bfb81a507d2b3a0a83926eca5247d",
"sha256": "5d429d566482ddb5e2424a4f6ac80782340fd2eb707595d601511d077d6caaba"
},
"downloads": -1,
"filename": "datapackage-1.15.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "568bfb81a507d2b3a0a83926eca5247d",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 85835,
"upload_time": "2021-02-24T09:43:18",
"upload_time_iso_8601": "2021-02-24T09:43:18.727656Z",
"url": "https://files.pythonhosted.org/packages/53/f3/d70f2f7dcb9883e586fa54f3937b9281242bde7751ed3162b4cdb047240e/datapackage-1.15.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "928167c3f467787b984afbd7b1543638",
"sha256": "1e91a18c866914dea0acfe2aec785e6ec583c33766b0682c740b30bb7de88c58"
},
"downloads": -1,
"filename": "datapackage-1.15.2.tar.gz",
"has_sig": false,
"md5_digest": "928167c3f467787b984afbd7b1543638",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 99775,
"upload_time": "2021-02-24T09:43:22",
"upload_time_iso_8601": "2021-02-24T09:43:22.155694Z",
"url": "https://files.pythonhosted.org/packages/c7/83/ef759d618745503e66c33aa9e218a954c3637a1b9a700ac9b368b5c9908b/datapackage-1.15.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-02-24 09:43:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "frictionlessdata",
"github_project": "datapackage-py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "datapackage"
}