Skip to main content
# infinity-data

This is a simple package that helps read Infinity data format and get data in such format.

## Quick start

### Get data

Just `pip install infdata`, and start getting data.

For example,
```
$ inf pull example.com/posts==crawler-1.0.0
```

pulls records that are posts from `example.com/posts`, `crawler-1.0.0` version.

### Publish data
```
$ int init # initiates folder .inf/
$ inf login # saves token to .inf/config
$ inf search example.com/posts # searches for dataset versions
$ inf push file.json # uploads Infinity JSON or JSON-L data to specified infinity server
```

**Note:** the tokens `['example.com/posts', 'crawler-1.0.0']` together define a unique `[source-specific, crawler-specific]` schema.

# Infinity JSON

Infinity JSON format includes a header line, which specifies schemas (`[S]`) and types (`[T]`) for its records.

Example:

```
[
{'': [[S],[T], 'x': [[S],[T]], 'y': [{'': [[S],[T]], 'z': [[S],[T]]}]},
{'x': '1,330.98', 'y': [{'z': 1}, {'u': 2}]},
{'x': '2,011.19', 'y': [{'z': 4}, {'u': 3}]},
]
```

The schemas, types specification for the empty string key `''` specifies the schema and type for the records themselves (required in every level separated by curly braces), whereas the rest of keys specify schemas and types for the data accessible via the keys.

This way, if we want to specify, that the `x` must be casted to a `float`, and means the [elevation](https://www.wikidata.org/wiki/Q2633778), we can do:

```
[
{'': [], 'x': {'': [['str'],['https://www.wikidata.org/wiki/Q2633778']]}},
{'x': '1,330.98', 'y': [{'z': 1}, {'u': 2}]},
{'x': '2,011.19', 'y': [{'z': 4}, {'u': 3}]},
]
```

If you want to additionally, add conversion rules, you can include lambda expression after the final type:

```
[
{'': [], 'x': {'': [['float', "lambda x: x.replace(',','')"],['https://www.wikidata.org/wiki/Q2633778']]}},
{'x': '1,330.98', 'y': [{'z': 1}, {'u': 2}]},
{'x': '2,011.19', 'y': [{'z': 4}, {'u': 3}]},
]
```

This way, the final data becomes:

```
from inf import normalize

normalize(
[
{'x': [['float', "lambda x: x.replace(',','')"],['https://www.wikidata.org/wiki/Q2633778']]},
{'x': '1,330.98', 'y': [{'z': 1}, {'u': 2}]},
{'x': '2,011.19', 'y': [{'z': 4}, {'u': 3}]},
]
)
```

Result is:

```
[
{'Q2633778': 1330.98, 'y': [{'z': 1}, {'u': 2}]},
{'Q2633778': 2011.19, 'y': [{'z': 4}, {'u': 3}]},
]
```

# Infinity CSV

Sometimes we want to include schema and type (`S`, `T`) into CSV. In that case, we use `|` to separate them:

```
Column Name|S|T,
```

For example:

```
Name||,Surname||,
```

If we want to enforce some rules, we could do then:

```
Name|str|https://www.wikidata.org/wiki/Q82799,Surname|str,lambda x: x[:10]|https://www.wikidata.org/wiki/Q101352,
```

Metadata

Release files for infdata 1.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for infdata 1.0.12
File Size Uploaded
infdata-1.0.12.tar.gz 16.4 kB Details

Release files / infdata-1.0.12.tar.gz

Download URL infdata-1.0.12.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d9717cf0403110e30cd059cdfe9500104279d7ae56bf09ec9e7ad11e7e851ac8
BLAKE2b-256 checksum
How to use checksums
774f58c0632e33b0950963d97e78170bf91d7589dbddf75a0d37c24c8e5e5825
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.12 This release

1 release file

1.0.11

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page