diff --git a/examples/Basic_usage/fluxnet_config.ini b/examples/Basic_usage/fluxnet_config.ini index bcea789..de0fa8d 100644 --- a/examples/Basic_usage/fluxnet_config.ini +++ b/examples/Basic_usage/fluxnet_config.ini @@ -6,6 +6,7 @@ station_longitude = -99.42 station_elevation = 611 anemometer_height = 3 missing_data_value = -9999 +date_parser = %Y%m%d [DATA] datestring_col = TIMESTAMP diff --git a/fluxdataqaqc/data.py b/fluxdataqaqc/data.py index b3d396d..cd9a086 100644 --- a/fluxdataqaqc/data.py +++ b/fluxdataqaqc/data.py @@ -1102,8 +1102,11 @@ def df(self): if 'date_parser' in dict(self.config.items('METADATA')): date_parse_str = self.config.get('METADATA','date_parser') - date_parser = lambda x: datetime.strptime(x, date_parse_str) - kwargs['date_parser'] = date_parser + #date_parser = lambda x: datetime.strptime(x, date_parse_str) + #kwargs['date_parser'] = date_parser + else: + date_parse_str = None + if 'load_all_vars' in dict(self.config.items('METADATA')): # if this option is listed (with any value) read all columns into df cols = self.header @@ -1124,7 +1127,10 @@ def df(self): usecols = cols, **kwargs ) - df[variables.get('date')] = pd.to_datetime(df[variables.get('date')]) + + df[variables.get('date')] = pd.to_datetime( + df[variables.get('date')], format=date_parse_str + ) if 'missing_data_value' in dict(self.config.items('METADATA')): # force na_val because sometimes with read_excel it doesn't work...