Skip to content

Commit

Permalink
Merge pull request #41 from EnAccess/add-zotero-sync-script
Browse files Browse the repository at this point in the history
Add Zotero sync script
  • Loading branch information
dmohns authored May 30, 2024
2 parents 6bb381b + 69ba87e commit 7144538
Show file tree
Hide file tree
Showing 6 changed files with 10,841 additions and 0 deletions.
1 change: 1 addition & 0 deletions datalayer/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.2
24 changes: 24 additions & 0 deletions datalayer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Datalayer

This directory contains a small Python script to sync the Zotero Library of the [Co-Design toolkit](https://www.zotero.org/groups/4998453/humanitarian_energy_co-design_toolbox/library) into this repository.

## Pre-requisites

- [Poetry](https://python-poetry.org/)
- [pyenv](https://github.com/pyenv/pyenv)
- [Zotero](https://www.zotero.org/) Account and [API key](https://www.zotero.org/settings/keys/new)
- (Optional) [direnv](https://direnv.net/)

## Installation

```sh
poetry install
```

Set environment variable `ZOTERO_API_KEY` to your previously configured API key.

## Running the script

```sh
poetry run python datalayer.py
```
23 changes: 23 additions & 0 deletions datalayer/datalayer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import json
import os

from pyzotero import zotero

ZOTERO_API_KEY = os.environ["ZOTERO_API_KEY"]


def sync():
# https://www.zotero.org/groups/4998453/humanitarian_energy_co-design_toolbox/library
zot = zotero.Zotero("4998453", "group", ZOTERO_API_KEY)
items = zot.items()

output_file = "../public/zotero_data.json"

with open(output_file, "w") as file:
json.dump(items, file, indent=2)

print(f"Data has been written to {output_file}")


if __name__ == "__main__":
sync()
Loading

0 comments on commit 7144538

Please sign in to comment.