44"""
55# Standard library
66import argparse
7- import csv
87import os
98import sys
109import textwrap
@@ -62,16 +61,6 @@ def parse_arguments():
6261 return args
6362
6463
65- def data_to_csv (args , data , file_path ):
66- if not args .enable_save :
67- return
68- os .makedirs (PATHS ["data_phase" ], exist_ok = True )
69- # emulate csv.unix_dialect
70- data .to_csv (
71- file_path , index = False , quoting = csv .QUOTE_ALL , lineterminator = "\n "
72- )
73-
74-
7564def process_product_totals (args , count_data ):
7665 """
7766 Processing count data: totals by product
@@ -111,7 +100,7 @@ def process_product_totals(args, count_data):
111100 data .items (), columns = ["CC legal tool product" , "Count" ]
112101 )
113102 file_path = shared .path_join (PATHS ["data_phase" ], "gcs_product_totals.csv" )
114- data_to_csv (args , data , file_path )
103+ shared . data_to_csv (args , data , file_path , PATHS )
115104
116105
117106def process_latest_prior_retired_totals (args , count_data ):
@@ -192,7 +181,7 @@ def process_latest_prior_retired_totals(args, count_data):
192181 file_path = shared .path_join (
193182 PATHS ["data_phase" ], f"gcs_status_{ key } _totals.csv"
194183 )
195- data_to_csv (args , dataframe , file_path )
184+ shared . data_to_csv (args , dataframe , file_path )
196185
197186
198187def process_totals_by_free_cultural (args , count_data ):
@@ -225,7 +214,7 @@ def process_totals_by_free_cultural(args, count_data):
225214 file_path = shared .path_join (
226215 PATHS ["data_phase" ], "gcs_totals_by_free_cultural.csv"
227216 )
228- data_to_csv (args , data , file_path )
217+ shared . data_to_csv (args , data , file_path )
229218
230219
231220def process_totals_by_restrictions (args , count_data ):
@@ -259,7 +248,7 @@ def process_totals_by_restrictions(args, count_data):
259248 file_path = shared .path_join (
260249 PATHS ["data_phase" ], "gcs_totals_by_restrictions.csv"
261250 )
262- data_to_csv (args , data , file_path )
251+ shared . data_to_csv (args , data , file_path )
263252
264253
265254def process_totals_by_language (args , data ):
@@ -280,7 +269,7 @@ def process_totals_by_language(args, data):
280269 file_path = shared .path_join (
281270 PATHS ["data_phase" ], "gcs_totals_by_language.csv"
282271 )
283- data_to_csv (args , data , file_path )
272+ shared . data_to_csv (args , data , file_path )
284273
285274
286275def process_totals_by_country (args , data ):
@@ -301,7 +290,7 @@ def process_totals_by_country(args, data):
301290 file_path = shared .path_join (
302291 PATHS ["data_phase" ], "gcs_totals_by_country.csv"
303292 )
304- data_to_csv (args , data , file_path )
293+ shared . data_to_csv (args , data , file_path )
305294
306295
307296def main ():
0 commit comments