Skip to content
Snippets Groups Projects
Commit 4d38c5bf authored by Alois Klink's avatar Alois Klink
Browse files

Make sure column names are all uppercase

Before, the CSV files jumped to using DATE as a column to using Date.
parent 2fabcfc5
No related branches found
No related tags found
No related merge requests found
...@@ -182,6 +182,20 @@ def daterange(from_time, to_time) -> typing.List[datetime.datetime]: ...@@ -182,6 +182,20 @@ def daterange(from_time, to_time) -> typing.List[datetime.datetime]:
return dates return dates
def uppercase_columns(pandas_dataset):
"""Makes sure all the column names are uppercase
Arguments:
pandas_dataset:
The dataset to uppercase column names of.
Warning, this modifies this object.
Returns:
The dataset with uppercase column names.
"""
pandas_dataset.columns = pandas_dataset.columns.str.upper()
return pandas_dataset
def combine_csvs(input_csv_files: list, output_loc): def combine_csvs(input_csv_files: list, output_loc):
"""Combines the given csv files into one big one. """Combines the given csv files into one big one.
...@@ -191,7 +205,8 @@ def combine_csvs(input_csv_files: list, output_loc): ...@@ -191,7 +205,8 @@ def combine_csvs(input_csv_files: list, output_loc):
input_csv_files: The list of csv files to combine. input_csv_files: The list of csv files to combine.
output_loc: Where the save the combined csv file. output_loc: Where the save the combined csv file.
""" """
combined = pd.concat([pd.read_csv(f) for f in input_csv_files]) combined = pd.concat([uppercase_columns(pd.read_csv(f))
for f in input_csv_files])
combined.to_csv(output_loc, index=False, encoding='utf-8') combined.to_csv(output_loc, index=False, encoding='utf-8')
def make_csv(location: Locations, def make_csv(location: Locations,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment