-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTabulate.py
More file actions
32 lines (26 loc) · 969 Bytes
/
Tabulate.py
File metadata and controls
32 lines (26 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pathlib import Path
import logging
import fire
from src.tabulate.configuration import parse_configuration
from src.tabulate.csv import write_csvs
from src.tabulate.process import process_file
from src.time_func import time_func
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')
def main(config: str):
config_path = Path(config).expanduser()
configuration = parse_configuration(config_path)
configuration.validate()
configuration.output_folder.mkdir(exist_ok=True)
data_files = list(configuration.data_folder.glob(configuration.file_pattern))
logging.info("Going over %s data files!", len(data_files))
tabulated = {}
for data_file in data_files:
process_file(data_file, tabulated)
with time_func("Writing CSVs"):
write_csvs(configuration, tabulated)
logging.info("DONE :)")
if __name__ == '__main__':
fire.Fire(main)