From 5ea5d8541372c79298c59014e45115402c3486ce Mon Sep 17 00:00:00 2001 From: Maria Grandury Date: Thu, 27 Jul 2023 12:01:32 +0200 Subject: [PATCH] chore: automate reordering of datasets.csv --- .github/workflows/readme-generation.yml | 9 +++++---- generate_datasets_table.py | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/readme-generation.yml b/.github/workflows/readme-generation.yml index 97e50a2..fd29928 100644 --- a/.github/workflows/readme-generation.yml +++ b/.github/workflows/readme-generation.yml @@ -1,7 +1,7 @@ name: Generate README on datasets.csv file update on: - push: + pull_request: branches: - main paths: @@ -24,6 +24,7 @@ jobs: git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" - git add README.md - git commit -m "Update datasets table" - git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:main + + git add datasets.csv README.md + git commit -m "Update datasets table and reorder datasets.csv" + git push origin "${{ github.head_ref }}" diff --git a/generate_datasets_table.py b/generate_datasets_table.py index 0af0e07..d7f3d29 100644 --- a/generate_datasets_table.py +++ b/generate_datasets_table.py @@ -1,6 +1,12 @@ import pandas as pd df = pd.read_csv("datasets.csv") + +# Sort the DataFrame by the 'name' column and save it +df.sort_values(by="name", inplace=True) +df.to_csv("datasets.csv", index=False) + +# Generate the datasets table table_content = df.to_markdown(index=False) with open("README.md", "r") as f: