From 8eeea264d072378224647cdee21b01d443f06fc4 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sun, 1 May 2022 23:56:49 +0200 Subject: [PATCH] Do not export line with empty value in statistics --- csvprocess.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/csvprocess.py b/csvprocess.py index 08a4f33..f443181 100755 --- a/csvprocess.py +++ b/csvprocess.py @@ -253,8 +253,14 @@ if __name__ == '__main__': logger.debug('Process indicator {}'.format(regex)) selection = srow.filter(regex=regex) + for attribute, value in selection.items(): logger.debug('check code: {}'.format(irow['code'])) + + # If value is NaN, then do not add the line + if pd.isna(value): + continue + if irow['code'].startswith('_'): start,end = get_single_date(attribute) else: @@ -263,7 +269,7 @@ if __name__ == '__main__': if start is None or end is None: logger.error('Can\'t process line, continue to next') continue - + logger.debug( 'town:{}, id_indic: {}, start: {}, end: {}, value:{}' .format( @@ -302,7 +308,7 @@ if __name__ == '__main__': export_csv(dep_capitals, args.export + '/cheflieudepartement.csv') export_csv(states_capitals, args.export + '/cheflieuregion.csv') export_csv(indicators, args.export + '/indicateur.csv', True) - export_csv(consolidated_stats, args.export + '/statistiques.csv') + export_csv(consolidated_stats, args.export + '/statistique.csv') t.stop() t.get_times_by_tag()