Skip to content

Commit

Permalink
add script
Browse files Browse the repository at this point in the history
  • Loading branch information
alifnaufalyasin committed Jul 31, 2023
1 parent 9a7a506 commit 63e89ca
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/generate-data-member.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Generate Data Member in Json
on:
push:
branches: [master]
workflow_dispatch:

jobs:
generate_data_member:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download csv file of member form in gsheet
run: |
curl -L -o ./scripts/dataMember.csv https://docs.google.com/spreadsheets/d/1SaXnuRt-1KXyDGS18KqU7cus4_IWNxpGhiVy0J1vz-U/export?format=csv
- name: run python script to convert csv to json
run: |
cd ./scripts
python script.py
git checkout -b production
cp ./dataMember.json ../data/dataMember.json
cd ..
rm ./scripts
21 changes: 21 additions & 0 deletions scripts/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import csv
import json

def csv_to_json(csv_file, json_file):
# Read CSV data and convert it to a list of dictionaries
with open(csv_file, 'r') as csvfile:
reader = csv.DictReader(csvfile)
data = [row for row in reader]

# Write the data to a JSON file
with open(json_file, 'w') as jsonfile:
json.dump(data, jsonfile, indent=4)

if __name__ == "__main__":
# Replace 'input.csv' with the path of your CSV file
csv_file_path = 'dataMember.csv'

# Replace 'output.json' with the desired path for the JSON output file
json_file_path = 'dataMember.json'

csv_to_json(csv_file_path, json_file_path)

0 comments on commit 63e89ca

Please sign in to comment.