From 4d38c5bfee6cad8d7a0971abc93521e8b0f96b68 Mon Sep 17 00:00:00 2001 From: Alois Klink <alois.klink@soton.ac.uk> Date: Thu, 30 May 2019 15:11:43 +0100 Subject: [PATCH] Make sure column names are all uppercase Before, the CSV files jumped to using DATE as a column to using Date. --- chimet-scraper.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/chimet-scraper.py b/chimet-scraper.py index fdb17b3..1563229 100644 --- a/chimet-scraper.py +++ b/chimet-scraper.py @@ -182,6 +182,20 @@ def daterange(from_time, to_time) -> typing.List[datetime.datetime]: 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): """Combines the given csv files into one big one. @@ -191,7 +205,8 @@ def combine_csvs(input_csv_files: list, output_loc): input_csv_files: The list of csv files to combine. 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') def make_csv(location: Locations, -- GitLab