From 05cd351f119034724641c30ae8d9b6885aff0d10 Mon Sep 17 00:00:00 2001 From: joyakis Date: Mon, 3 Apr 2023 02:11:13 +0300 Subject: [PATCH] Add process-json workflow Signed-off-by: joyakis --- .github/workflows/process-json-file.yml | 43 +++++++++++++++++++++++++ .github/workflows/requirements.txt | 3 ++ Data/data.py | 19 +++++++++++ 3 files changed, 65 insertions(+) create mode 100644 .github/workflows/process-json-file.yml create mode 100644 .github/workflows/requirements.txt create mode 100644 Data/data.py diff --git a/.github/workflows/process-json-file.yml b/.github/workflows/process-json-file.yml new file mode 100644 index 000000000..375b73ab6 --- /dev/null +++ b/.github/workflows/process-json-file.yml @@ -0,0 +1,43 @@ +name: process-json-file + +on: + # Run the workflow every day at 6:00am UTC + schedule: + - cron: "0 6 * * *" + +jobs: + process-json: + runs-on: ubuntu-latest + + steps: + # Checkout the code from the repository + - name: Checkout code + uses: actions/checkout@v2 + + # Install Python + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + # Install dependencies + - name: Install dependencies + run: pip install -r requirements.txt + + # Run the Python script to process the JSON file + - name: Process JSON file + run: python data.py + + # Commit changes to the repository + - name: Commit changes + run: | + git config --global user.name "Your Name" + git config --global user.email "youremail@example.com" + git add processed_data.json + git commit -m "Process data" + + # Push changes to the remote repository + - name: Push changes + uses: ad-m/github-push-action@v0.5.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/requirements.txt b/.github/workflows/requirements.txt new file mode 100644 index 000000000..48989c65e --- /dev/null +++ b/.github/workflows/requirements.txt @@ -0,0 +1,3 @@ +geopandas +matplotlib +pandas \ No newline at end of file diff --git a/Data/data.py b/Data/data.py new file mode 100644 index 000000000..f974548a0 --- /dev/null +++ b/Data/data.py @@ -0,0 +1,19 @@ +import json + +# Read in the JSON data +with open('KEN_AL2_Kenya_GEZ.json', 'r') as f: + data = json.load(f) + +# Process the data +processed_data = [] +for item in data: + # Perform some transformation on the data + processed_item = { + 'name': item['name'], + 'age': item['gez_code'] * 2 + } + processed_data.append(processed_item) + +# Write the processed data to a new JSON file +with open('processed_data.json', 'w') as f: + json.dump(processed_data, f)