File size: 569 Bytes
5da6fa2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import functions
import pandas as pd

def main(
    in_file: str,
    out_file: str,
    func: str = '',
):
    try:
        # Default using jsonl
        processor = getattr(functions, func)
        df = pd.read_json(in_file, lines=True)
        out = processor.process(df)
        with open(out_file, 'w', encoding='utf-8') as file:
            out.to_json(file, force_ascii=False, lines=True, orient='records')
    except ValueError as e:
        print(e)

if __name__ == '__main__':
    import fire
    fire.Fire(main)