refactoring
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from GoogleAnalytics.ResolutionProvider import Resolution, ResolutionProvider
|
from GoogleAnalytics.ResolutionProvider import Resolution, ResolutionProvider
|
||||||
|
from GoogleAnalytics.GoogleAnalyticsReader import GoogleAnalyticsReader
|
||||||
|
from GoogleAnalytics.RegionCountsByClickedBatchcodeProvider import RegionCountsByClickedBatchcodeProvider
|
||||||
|
|
||||||
class CountryCountsByClickedBatchcodeProvider:
|
class CountryCountsByClickedBatchcodeProvider:
|
||||||
|
|
||||||
@@ -22,34 +24,14 @@ class CountryCountsByClickedBatchcodeProvider:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _getCityCountsByClickedBatchcode(file):
|
def _getCityCountsByClickedBatchcode(file):
|
||||||
return CountryCountsByClickedBatchcodeProvider._read_csv(
|
return RegionCountsByClickedBatchcodeProvider._getCityCountsByClickedBatchcode(file)
|
||||||
file = file,
|
|
||||||
columns = {
|
|
||||||
'Country': 'COUNTRY',
|
|
||||||
'Region': 'REGION',
|
|
||||||
'City': 'CITY',
|
|
||||||
'Event count': 'CITY_COUNT_BY_VAX_LOT'
|
|
||||||
},
|
|
||||||
index_columns = ['COUNTRY', 'REGION', 'CITY'])
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _getCountryCountsByClickedBatchcode_fromCountryResolution(file):
|
def _getCountryCountsByClickedBatchcode_fromCountryResolution(file):
|
||||||
return CountryCountsByClickedBatchcodeProvider._read_csv(
|
return GoogleAnalyticsReader.read_csv(
|
||||||
file = file,
|
file = file,
|
||||||
columns = {
|
columns = {
|
||||||
'Country': 'COUNTRY',
|
'Country': 'COUNTRY',
|
||||||
'Event count': 'COUNTRY_COUNT_BY_VAX_LOT'
|
'Event count': 'COUNTRY_COUNT_BY_VAX_LOT'
|
||||||
},
|
},
|
||||||
index_columns = ['COUNTRY'])
|
index_columns = ['COUNTRY'])
|
||||||
|
|
||||||
# FK-TODO: move this method to a new class named GoogleAnalytics.GoogleAnalyticsReader
|
|
||||||
@staticmethod
|
|
||||||
def _read_csv(file, columns, index_columns):
|
|
||||||
dataframe = pd.read_csv(file, index_col = 0, skiprows = [0, 1, 2, 3, 4, 5, 7])
|
|
||||||
dataframe.index.name = 'VAX_LOT'
|
|
||||||
dataframe.rename(
|
|
||||||
columns = columns,
|
|
||||||
inplace = True)
|
|
||||||
dataframe.set_index(index_columns, append = True, inplace = True)
|
|
||||||
return dataframe
|
|
||||||
|
|
||||||
13
src/GoogleAnalytics/GoogleAnalyticsReader.py
Normal file
13
src/GoogleAnalytics/GoogleAnalyticsReader.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
class GoogleAnalyticsReader:
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_csv(file, columns, index_columns):
|
||||||
|
dataframe = pd.read_csv(file, index_col = 0, skiprows = [0, 1, 2, 3, 4, 5, 7])
|
||||||
|
dataframe.index.name = 'VAX_LOT'
|
||||||
|
dataframe.rename(
|
||||||
|
columns = columns,
|
||||||
|
inplace = True)
|
||||||
|
dataframe.set_index(index_columns, append = True, inplace = True)
|
||||||
|
return dataframe
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from GoogleAnalytics.ResolutionProvider import Resolution, ResolutionProvider
|
from GoogleAnalytics.GoogleAnalyticsReader import GoogleAnalyticsReader
|
||||||
from CountryCountsByClickedBatchcodeProvider import CountryCountsByClickedBatchcodeProvider
|
|
||||||
|
|
||||||
class RegionCountsByClickedBatchcodeProvider:
|
class RegionCountsByClickedBatchcodeProvider:
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ class RegionCountsByClickedBatchcodeProvider:
|
|||||||
# FK-TODO: delegate same method CountryCountsByClickedBatchcodeProvider._getCityCountsByClickedBatchcode() to here
|
# FK-TODO: delegate same method CountryCountsByClickedBatchcodeProvider._getCityCountsByClickedBatchcode() to here
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _getCityCountsByClickedBatchcode(file):
|
def _getCityCountsByClickedBatchcode(file):
|
||||||
return CountryCountsByClickedBatchcodeProvider._read_csv(
|
return GoogleAnalyticsReader.read_csv(
|
||||||
file = file,
|
file = file,
|
||||||
columns = {
|
columns = {
|
||||||
'Country': 'COUNTRY',
|
'Country': 'COUNTRY',
|
||||||
|
|||||||
Reference in New Issue
Block a user