Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JSON Lines #65

Closed
wants to merge 1 commit into from
Closed

Use JSON Lines #65

wants to merge 1 commit into from

Conversation

edsu
Copy link
Contributor

@edsu edsu commented Jun 28, 2024

This is an experiment in using JSON Lines for our harvested JSON data instead of CSV.

This commit moves our sul_pub, dimensions and openalex harvesters over
to writing records as JSON Lines (jsonl). This means we will preserve
the dictionary and list data structures we received from the APIs and
will be able to use them for querying later, e.g. ORCID IDs embedded in
author objects.

Reading in JSON-L can be achieved with Pandas like:

pandas.read_json('data.jsonl', orient='records', lines=True)

and Polars:

polars.read_ndjson('data.jsonl')

or lazily:

polars.scan_ndjson('data.jsonl')

@edsu edsu force-pushed the use-jsonl branch 3 times, most recently from fab0855 to bea6d67 Compare June 28, 2024 21:59
This commit moves our sul_pub, dimensions and openalex harvesters over
to writing records as JSON Lines (jsonl). This means we will preserve
the dictionary and list data structures we received from the APIs and
will be able to use them for querying later, e.g. ORCID IDs embedded in
author objects.

Reading in JSON-L can be achieved with Pandas like:

```python
pandas.read_json('data.jsonl', orient='records', lines=True)
```

and Polars:

```python
polars.read_ndjson('data.jsonl')
```

or lazily:

```python
polars.scan_ndjson('data.jsonl')
```
@edsu edsu marked this pull request as draft June 28, 2024 22:18
@edsu
Copy link
Contributor Author

edsu commented Jul 1, 2024

This was a useful experiment to see how the structure of the harvested data could be preserved. But I don't think it's strictly necessary. Perhaps it's something to keep in mind for the future though?

@edsu edsu closed this Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant