|
11 | 11 | import traceback |
12 | 12 |
|
13 | 13 | # Third-party |
14 | | -import pandas as pd |
15 | 14 | from pygments import highlight |
16 | 15 | from pygments.formatters import TerminalFormatter |
17 | 16 | from pygments.lexers import PythonTracebackLexer |
@@ -80,7 +79,7 @@ def gcs_intro(args): |
80 | 79 | ) |
81 | 80 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
82 | 81 | name_label = "CC legal tool product" |
83 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 82 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
84 | 83 | total_count = f"{data['Count'].sum():,d}" |
85 | 84 | shared.update_readme( |
86 | 85 | args, |
@@ -111,7 +110,8 @@ def plot_products(args): |
111 | 110 | ) |
112 | 111 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
113 | 112 | name_label = "CC legal tool product" |
114 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 113 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
| 114 | + |
115 | 115 | data = data[::-1] # reverse order |
116 | 116 |
|
117 | 117 | title = "Products totals and percentages" |
@@ -156,7 +156,7 @@ def plot_tool_status(args): |
156 | 156 | ) |
157 | 157 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
158 | 158 | name_label = "CC legal tool" |
159 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 159 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
160 | 160 | data.sort_values(name_label, ascending=False, inplace=True) |
161 | 161 |
|
162 | 162 | title = "CC legal tools status" |
@@ -199,7 +199,7 @@ def plot_latest_tools(args): |
199 | 199 | ) |
200 | 200 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
201 | 201 | name_label = "CC legal tool" |
202 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 202 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
203 | 203 | data.sort_values(name_label, ascending=False, inplace=True) |
204 | 204 |
|
205 | 205 | title = "Latest CC legal tools" |
@@ -241,7 +241,7 @@ def plot_prior_tools(args): |
241 | 241 | ) |
242 | 242 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
243 | 243 | name_label = "CC legal tool" |
244 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 244 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
245 | 245 | data.sort_values(name_label, ascending=False, inplace=True) |
246 | 246 |
|
247 | 247 | title = "Prior CC legal tools" |
@@ -286,7 +286,7 @@ def plot_retired_tools(args): |
286 | 286 | ) |
287 | 287 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
288 | 288 | name_label = "CC legal tool" |
289 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 289 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
290 | 290 | data.sort_values(name_label, ascending=False, inplace=True) |
291 | 291 |
|
292 | 292 | title = "Retired CC legal tools" |
@@ -332,7 +332,7 @@ def plot_countries_highest_usage(args): |
332 | 332 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
333 | 333 | name_label = "Country" |
334 | 334 | data_label = "Count" |
335 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 335 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
336 | 336 | total_count = f"{data['Count'].sum():,d}" |
337 | 337 | data.sort_values(data_label, ascending=False, inplace=True) |
338 | 338 | data = data[:10] # limit to highest 10 |
@@ -385,7 +385,7 @@ def plot_languages_highest_usage(args): |
385 | 385 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
386 | 386 | name_label = "Language" |
387 | 387 | data_label = "Count" |
388 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 388 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
389 | 389 | total_count = f"{data['Count'].sum():,d}" |
390 | 390 | data.sort_values(data_label, ascending=False, inplace=True) |
391 | 391 | data = data[:10] # limit to highest 10 |
@@ -439,7 +439,7 @@ def plot_free_culture(args): |
439 | 439 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
440 | 440 | name_label = "Category" |
441 | 441 | data_label = "Count" |
442 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 442 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
443 | 443 |
|
444 | 444 | title = "Approved for Free Cultural Works" |
445 | 445 | plt = plot.combined_plot( |
|
0 commit comments