+
+def agregate():
+ CSV_HEADER = 'Date;Libellé;Montant(EUROS);Montant(FRANCS)'
+
+ account_files = os.listdir(LOCAL_DIR)
+ for account_file in account_files:
+ if not account_file.endswith('.last.csv'):
+ continue
+
+ account = account_file[:-len('.last.csv')]
+ logging.debug('Agregating %s', account)
+
+ if os.access(LOCAL_DIR + account + '.csv', os.F_OK):
+ pass
+ else:
+ logging.warning('Master csv file not found for %s: creating', account)
+ masterfile = open(LOCAL_DIR + account + '.csv', 'w', encoding='utf-8')
+
+ past_headers = False
+ for line in open(LOCAL_DIR + account_file).read().split('\n'):
+ if not line:
+ continue
+ if past_headers:
+ masterfile.write(line + '\n')
+ elif line == CSV_HEADER:
+ past_headers = True
+
+