|
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,8 @@ 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) |
| 83 | + data.set_index(name_label, inplace=True) |
84 | 84 | total_count = f"{data['Count'].sum():,d}" |
85 | 85 | shared.update_readme( |
86 | 86 | args, |
@@ -111,7 +111,9 @@ def plot_products(args): |
111 | 111 | ) |
112 | 112 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
113 | 113 | name_label = "CC legal tool product" |
114 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 114 | + data = shared.open_data_file(LOGGER, file_path) |
| 115 | + data.set_index(name_label, inplace=True) |
| 116 | + |
115 | 117 | data = data[::-1] # reverse order |
116 | 118 |
|
117 | 119 | title = "Products totals and percentages" |
@@ -156,7 +158,8 @@ def plot_tool_status(args): |
156 | 158 | ) |
157 | 159 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
158 | 160 | name_label = "CC legal tool" |
159 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 161 | + data = shared.open_data_file(LOGGER, file_path) |
| 162 | + data.set_index(name_label, inplace=True) |
160 | 163 | data.sort_values(name_label, ascending=False, inplace=True) |
161 | 164 |
|
162 | 165 | title = "CC legal tools status" |
@@ -199,7 +202,8 @@ def plot_latest_tools(args): |
199 | 202 | ) |
200 | 203 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
201 | 204 | name_label = "CC legal tool" |
202 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 205 | + data = shared.open_data_file(LOGGER, file_path) |
| 206 | + data.set_index(name_label, inplace=True) |
203 | 207 | data.sort_values(name_label, ascending=False, inplace=True) |
204 | 208 |
|
205 | 209 | title = "Latest CC legal tools" |
@@ -241,7 +245,8 @@ def plot_prior_tools(args): |
241 | 245 | ) |
242 | 246 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
243 | 247 | name_label = "CC legal tool" |
244 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 248 | + data = shared.open_data_file(LOGGER, file_path) |
| 249 | + data.set_index(name_label, inplace=True) |
245 | 250 | data.sort_values(name_label, ascending=False, inplace=True) |
246 | 251 |
|
247 | 252 | title = "Prior CC legal tools" |
@@ -286,7 +291,8 @@ def plot_retired_tools(args): |
286 | 291 | ) |
287 | 292 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
288 | 293 | name_label = "CC legal tool" |
289 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 294 | + data = shared.open_data_file(LOGGER, file_path) |
| 295 | + data.set_index(name_label, inplace=True) |
290 | 296 | data.sort_values(name_label, ascending=False, inplace=True) |
291 | 297 |
|
292 | 298 | title = "Retired CC legal tools" |
@@ -332,7 +338,8 @@ def plot_countries_highest_usage(args): |
332 | 338 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
333 | 339 | name_label = "Country" |
334 | 340 | data_label = "Count" |
335 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 341 | + data = shared.open_data_file(LOGGER, file_path) |
| 342 | + data.set_index(name_label, inplace=True) |
336 | 343 | total_count = f"{data['Count'].sum():,d}" |
337 | 344 | data.sort_values(data_label, ascending=False, inplace=True) |
338 | 345 | data = data[:10] # limit to highest 10 |
@@ -385,7 +392,8 @@ def plot_languages_highest_usage(args): |
385 | 392 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
386 | 393 | name_label = "Language" |
387 | 394 | data_label = "Count" |
388 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 395 | + data = shared.open_data_file(LOGGER, file_path) |
| 396 | + data.set_index(name_label, inplace=True) |
389 | 397 | total_count = f"{data['Count'].sum():,d}" |
390 | 398 | data.sort_values(data_label, ascending=False, inplace=True) |
391 | 399 | data = data[:10] # limit to highest 10 |
@@ -439,7 +447,7 @@ def plot_free_culture(args): |
439 | 447 | LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}") |
440 | 448 | name_label = "Category" |
441 | 449 | data_label = "Count" |
442 | | - data = pd.read_csv(file_path, index_col=name_label) |
| 450 | + data = shared.open_data_file(LOGGER, file_path, index_col=name_label) |
443 | 451 |
|
444 | 452 | title = "Approved for Free Cultural Works" |
445 | 453 | plt = plot.combined_plot( |
|
0 commit comments