From 77f88b4f158a38e9f3f74cd154def56fb8d713d8 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Sat, 30 Sep 2023 17:05:59 +0200 Subject: [PATCH] refactoring --- ...CountryCountsByClickedBatchcodeProvider.py | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/CountryCountsByClickedBatchcodeProvider.py b/src/CountryCountsByClickedBatchcodeProvider.py index d24365f4c3c..4a9913c4cef 100644 --- a/src/CountryCountsByClickedBatchcodeProvider.py +++ b/src/CountryCountsByClickedBatchcodeProvider.py @@ -4,30 +4,32 @@ class CountryCountsByClickedBatchcodeProvider: @staticmethod def getCountryCountsByClickedBatchcode(file): - exploration = pd.read_csv(file, index_col = 0, skiprows = [0, 1, 2, 3, 4, 5, 7]) - exploration.index.name = 'VAX_LOT' - exploration.rename( - columns = - { + return CountryCountsByClickedBatchcodeProvider._read_csv( + file = file, + columns = { 'Country': 'COUNTRY', 'Event count': 'COUNTRY_COUNT_BY_VAX_LOT' }, - inplace = True) - exploration.set_index('COUNTRY', append = True, inplace = True) - return exploration - + index_columns = ['COUNTRY']) + @staticmethod def getCityCountsByClickedBatchcode(file): - exploration = pd.read_csv(file, index_col = 0, skiprows = [0, 1, 2, 3, 4, 5, 7]) - exploration.index.name = 'VAX_LOT' - exploration.rename( - columns = - { + return CountryCountsByClickedBatchcodeProvider._read_csv( + file = file, + columns = { 'Country': 'COUNTRY', 'Region': 'REGION', 'City': 'CITY', 'Event count': 'CITY_COUNT_BY_VAX_LOT' }, + index_columns = ['COUNTRY', 'REGION', 'CITY']) + + @staticmethod + def _read_csv(file, columns, index_columns): + exploration = pd.read_csv(file, index_col = 0, skiprows = [0, 1, 2, 3, 4, 5, 7]) + exploration.index.name = 'VAX_LOT' + exploration.rename( + columns = columns, inplace = True) - exploration.set_index(['COUNTRY', 'REGION', 'CITY'], append = True, inplace = True) + exploration.set_index(index_columns, append = True, inplace = True) return exploration