danielrosehill commited on
Commit
dafc41d
Β·
1 Parent(s): 8e9e1f0
.github/scripts/update_stats.py CHANGED
@@ -5,6 +5,7 @@ import matplotlib.pyplot as plt
5
  from datetime import datetime
6
  from pathlib import Path
7
  import os
 
8
 
9
  # Get the repository root (works both for local and GitHub Actions)
10
  if 'GITHUB_WORKSPACE' in os.environ:
@@ -39,10 +40,23 @@ def update_csv():
39
  except FileNotFoundError:
40
  rows = [["Date", "Total Downloads"]]
41
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  with open(CSV_PATH, mode='w', newline='') as file:
43
  writer = csv.writer(file)
44
  writer.writerows(rows)
45
- writer.writerow([today, downloads])
 
46
 
47
  def generate_image():
48
  data = pd.read_csv(CSV_PATH)
@@ -60,27 +74,32 @@ def generate_image():
60
  plt.tight_layout()
61
  plt.savefig(IMAGE_PATH)
62
  plt.close()
 
 
63
 
64
  def update_readme():
 
 
 
65
  with open(README_PATH, 'r') as file:
66
  content = file.read()
67
 
68
- start_marker = "## Download Statistics"
69
- image_text = f"\n\n![Download Statistics](download_statistics.png)\n"
70
-
71
- if start_marker not in content:
72
- content += f"\n\n{start_marker}{image_text}"
73
- else:
74
- parts = content.split(start_marker)
75
- next_section = parts[1].find("##")
76
- if next_section == -1:
77
- parts[1] = image_text
78
  else:
79
- parts[1] = image_text + parts[1][next_section:]
80
- content = start_marker.join(parts)
81
 
82
  with open(README_PATH, 'w') as file:
83
  file.write(content)
 
 
84
 
85
  if __name__ == "__main__":
86
  update_csv()
 
5
  from datetime import datetime
6
  from pathlib import Path
7
  import os
8
+ import re
9
 
10
  # Get the repository root (works both for local and GitHub Actions)
11
  if 'GITHUB_WORKSPACE' in os.environ:
 
40
  except FileNotFoundError:
41
  rows = [["Date", "Total Downloads"]]
42
 
43
+ # Check if today's date is already in the CSV
44
+ today_exists = False
45
+ for i, row in enumerate(rows):
46
+ if len(row) > 0 and row[0] == today:
47
+ rows[i] = [today, downloads]
48
+ today_exists = True
49
+ break
50
+
51
+ # If today's date is not in the CSV, add it
52
+ if not today_exists:
53
+ rows.append([today, downloads])
54
+
55
  with open(CSV_PATH, mode='w', newline='') as file:
56
  writer = csv.writer(file)
57
  writer.writerows(rows)
58
+
59
+ print(f"Updated CSV with {downloads} downloads for {today}")
60
 
61
  def generate_image():
62
  data = pd.read_csv(CSV_PATH)
 
74
  plt.tight_layout()
75
  plt.savefig(IMAGE_PATH)
76
  plt.close()
77
+
78
+ print(f"Generated download statistics image at {IMAGE_PATH}")
79
 
80
  def update_readme():
81
+ # The badge in the README is already dynamic and will update automatically
82
+ # This function ensures the download_statistics.png image is properly referenced
83
+
84
  with open(README_PATH, 'r') as file:
85
  content = file.read()
86
 
87
+ # Check if we need to add a download statistics section with the image
88
+ if "## Download Statistics" not in content and "![Download Statistics]" not in content:
89
+ # Find a good place to insert the download statistics section
90
+ maintenance_section = "## πŸ”§ Development and Maintenance"
91
+ if maintenance_section in content:
92
+ # Insert before the maintenance section
93
+ parts = content.split(maintenance_section)
94
+ content = parts[0] + "\n## Download Statistics\n\n![Download Statistics](download_statistics.png)\n\n" + maintenance_section + parts[1]
 
 
95
  else:
96
+ # Insert at the end of the file
97
+ content += "\n\n## Download Statistics\n\n![Download Statistics](download_statistics.png)\n"
98
 
99
  with open(README_PATH, 'w') as file:
100
  file.write(content)
101
+
102
+ print(f"Updated README with download statistics section")
103
 
104
  if __name__ == "__main__":
105
  update_csv()
.github/workflows/update_downloads.yml CHANGED
@@ -12,13 +12,13 @@ jobs:
12
  - uses: actions/setup-python@v3
13
  with:
14
  python-version: '3.x'
15
- - run: pip install requests
16
  - name: Update stats
17
  run: python .github/scripts/update_stats.py
18
  - name: Commit changes
19
  run: |
20
  git config --local user.email "[email protected]"
21
  git config --local user.name "GitHub Action"
22
- git add daily_downloads.csv
23
  git commit -m "Update download stats" || exit 0
24
  git push
 
12
  - uses: actions/setup-python@v3
13
  with:
14
  python-version: '3.x'
15
+ - run: pip install -r requirements.txt
16
  - name: Update stats
17
  run: python .github/scripts/update_stats.py
18
  - name: Commit changes
19
  run: |
20
  git config --local user.email "[email protected]"
21
  git config --local user.name "GitHub Action"
22
+ git add daily_downloads.csv download_statistics.png
23
  git commit -m "Update download stats" || exit 0
24
  git push
README.md CHANGED
@@ -3,7 +3,7 @@ language:
3
  - en
4
  pretty_name: IFVI Value Factors - Derivative Dataset For Analysis
5
  ---
6
- ![alt text](resources/images/graphics/3.png)
7
 
8
  [![GitHub Repository](https://img.shields.io/badge/GitHub-Repository-blue?logo=github)](https://github.com/danielrosehill/Global-Value-Factors-Explorer-Dataset)
9
  [![Hugging Face Dataset](https://img.shields.io/badge/Hugging%20Face-Dataset-orange?logo=huggingface)](https://huggingface.co/datasets/danielrosehill/ifvi_valuefactors_deriv)
@@ -55,8 +55,11 @@ ifvi_valuefactors_deriv/
55
  β”‚
56
  β”œβ”€β”€ examples/ # Example applications using the dataset
57
  β”‚
58
- └── resources/ # Additional resources
59
- └── images/ # Images used in documentation
 
 
 
60
  ```
61
 
62
  For more details on the repository structure, see [REPOSITORY_STRUCTURE.md](REPOSITORY_STRUCTURE.md).
@@ -69,10 +72,6 @@ This repository reflects GVFD Version 1 (October 15th, 2024). It is not guarant
69
 
70
  This derivative dataset is subject to the same terms of use as the original database, available in `license.md` at the repository root. These licensing conditions are stipulated by the International Foundation for Valuing Impacts. At the time of writing, the licensing terms provide for wide use of the data on a complimentary basis (including by account preparers) with limited exclusions to that position for those looking to integrate the data into commercial data products for which licensing charges apply. Questions regarding licensing of the database and requests for clarification regarding allowable uses and any other queries regarding compliance with the terms of their license should be referred to the IFVI.
71
 
72
- ## πŸ“… Versioning
73
-
74
- This repository reflects GVFD Version 1 (October 15th, 2024). It is not guaranteed to be the most recent version. Consult the IFVI website for the latest data and updates. While this repository aims to mirror the original GVFD, using this data for official purposes requires referencing the complete IFVI documentation, which is not included here.
75
-
76
  <a id="data-formatting"></a>
77
  ## πŸ—‚οΈ Data Formatting
78
 
@@ -97,6 +96,22 @@ No material data changes were made. Modifications are limited to formatting and
97
  * Removal of US dollar signs for easier database integration.
98
  * Standardization of 12 country names to more common versions (e.g., "Bahamas, The" to "Bahamas") and mapping all territories to their ISO-3166 Alpha-2 codes for clarity.
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  <a id="release-notes-for-v2"></a>
101
 
102
  ---
 
3
  - en
4
  pretty_name: IFVI Value Factors - Derivative Dataset For Analysis
5
  ---
6
+ ![IFVI Value Factors](images/graphics/3.png)
7
 
8
  [![GitHub Repository](https://img.shields.io/badge/GitHub-Repository-blue?logo=github)](https://github.com/danielrosehill/Global-Value-Factors-Explorer-Dataset)
9
  [![Hugging Face Dataset](https://img.shields.io/badge/Hugging%20Face-Dataset-orange?logo=huggingface)](https://huggingface.co/datasets/danielrosehill/ifvi_valuefactors_deriv)
 
55
  β”‚
56
  β”œβ”€β”€ examples/ # Example applications using the dataset
57
  β”‚
58
+ β”œβ”€β”€ images/ # Images used in documentation
59
+ β”‚ β”œβ”€β”€ cards/ # Card images for visual representation
60
+ β”‚ └── graphics/ # Graphics and visual elements
61
+ β”‚
62
+ └── resources/ # Additional resources and reference data
63
  ```
64
 
65
  For more details on the repository structure, see [REPOSITORY_STRUCTURE.md](REPOSITORY_STRUCTURE.md).
 
72
 
73
  This derivative dataset is subject to the same terms of use as the original database, available in `license.md` at the repository root. These licensing conditions are stipulated by the International Foundation for Valuing Impacts. At the time of writing, the licensing terms provide for wide use of the data on a complimentary basis (including by account preparers) with limited exclusions to that position for those looking to integrate the data into commercial data products for which licensing charges apply. Questions regarding licensing of the database and requests for clarification regarding allowable uses and any other queries regarding compliance with the terms of their license should be referred to the IFVI.
74
 
 
 
 
 
75
  <a id="data-formatting"></a>
76
  ## πŸ—‚οΈ Data Formatting
77
 
 
96
  * Removal of US dollar signs for easier database integration.
97
  * Standardization of 12 country names to more common versions (e.g., "Bahamas, The" to "Bahamas") and mapping all territories to their ISO-3166 Alpha-2 codes for clarity.
98
 
99
+ ## πŸ”§ Development and Maintenance
100
+
101
+ This repository includes scripts for maintaining download statistics and other metadata. To contribute or run these scripts locally:
102
+
103
+ 1. Install the required dependencies:
104
+ ```bash
105
+ pip install -r requirements.txt
106
+ ```
107
+
108
+ 2. Update download statistics manually:
109
+ ```bash
110
+ python3 .github/scripts/update_stats.py
111
+ ```
112
+
113
+ The repository is configured with GitHub Actions to automatically update download statistics daily.
114
+
115
  <a id="release-notes-for-v2"></a>
116
 
117
  ---
REPOSITORY_STRUCTURE.md CHANGED
@@ -32,8 +32,11 @@ ifvi_valuefactors_deriv/
32
  β”‚ β”œβ”€β”€ economic-impact/ # Examples for economic impact assessment
33
  β”‚ └── regional-comparison/ # Examples for regional comparisons
34
  β”‚
35
- β”œβ”€β”€ resources/ # Additional resources
36
- β”‚ └── images/ # Images used in documentation
 
 
 
37
  β”‚
38
  └── internal/ # Internal repository management (not for public use)
39
  β”œβ”€β”€ archive/ # Archived files
 
32
  β”‚ β”œβ”€β”€ economic-impact/ # Examples for economic impact assessment
33
  β”‚ └── regional-comparison/ # Examples for regional comparisons
34
  β”‚
35
+ β”œβ”€β”€ images/ # Images used in documentation
36
+ β”‚ β”œβ”€β”€ cards/ # Card images for visual representation
37
+ β”‚ └── graphics/ # Graphics and visual elements
38
+ β”‚
39
+ β”œβ”€β”€ resources/ # Additional resources and reference data
40
  β”‚
41
  └── internal/ # Internal repository management (not for public use)
42
  β”œβ”€β”€ archive/ # Archived files
archive/old-readme.md DELETED
@@ -1,36 +0,0 @@
1
- ---
2
- language:
3
- - en
4
- pretty_name: IFVI Value Factors - Derivative Dataset For Analysis
5
- size_categories:
6
- - 1K<n<10K
7
- ---
8
-
9
- ## Dataset Description
10
- This dataset contains value factors for quantifying environmental impacts in monetary terms. It includes JSON files for structured data, PDFs for detailed reports, and CSVs for tabular data.
11
-
12
- This repository contains a derivative data set of the International Foundation for Valuing Impacts Global Value Factor Database, which was released during UN Climate Week in 2024.
13
-
14
- This derivative data set was originally compiled by me, Daniel Rosehill, released onto Github as a repository and is now copied and made available also on Hugging Face.
15
-
16
- The derivative data set is merely a reformatting of the original data, which was released in XSLM format.
17
-
18
- The reformatted and reshaped data set provides the same data, but in JSON and CSV format to support data analysis and visualization workloads.
19
-
20
- Some other minor formatting changes were made, such as removing the US dollar symbol from numeric fields where they appeared (instead the currency is noted in metadata files), but no substantive changes were made to either the data or its constitution.
21
-
22
- The dataset consists of a range of value factors which are almost all segmented on a geographical basis.
23
-
24
- The purpose of these value factors is to enable companies to convert their environmental impacts into monetary terms in support of a practice known as impact accounting.
25
-
26
- In the envisioned use, these value factors would be paired with companies' data about their greenhouse gas emissions (GHG), land use, wastewater consumption and pollution and other impacts.
27
-
28
- Those would be integrated into the preparation of financial accounts. This data set is shared to this platform with the kind permission of the IFVI whose only stipulation is that users should adhere to the license which is provided at the root of this repository. Although this summary is not a substitute for reading the license, the licensing generally permits non commercial use of the data. Usage requests can additionally be made directly to IFVI.
29
-
30
- Beyond the use case for account preparers there are other potentially interesting use cases in these value factors, which have been formulated on the basis of the best scientific opinion.
31
-
32
- They could be used in modeling government policy decisions to incentivise or disincentivise environmental activities by non profit seeking to. understand or estimate the extent of companies' non financial impacts among other uses.
33
-
34
- This dataset may or may not be the latest version of the GVFD and the original database should in all cases be considered the authoritative source that can be downloaded via the IFVI's website at ifvi.org.
35
-
36
- Thank you for your interest and if you have made any interesting use of this data, please do feel free to reach out.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
backups/readme-versions/050124.md DELETED
The diff for this file is too large to render. See raw diff
 
daily_downloads.csv CHANGED
@@ -1,3 +1,4 @@
1
  Date,Total Downloads
2
  2025-01-05,275
3
  2025-01-07,288
 
 
1
  Date,Total Downloads
2
  2025-01-05,275
3
  2025-01-07,288
4
+ 2025-03-18,847
download_statistics.png CHANGED
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ requests>=2.25.0
2
+ pandas>=1.2.0
3
+ matplotlib>=3.3.0
4
+ numpy>=1.19.0