forked from rali-udem/arpi_air_canada
-
Notifications
You must be signed in to change notification settings - Fork 0
/
import_excel.py
31 lines (24 loc) · 872 Bytes
/
import_excel.py
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
"""
This script converts the original Excel files to binary format. The import function is
very slow, but need only be run once.
"""
import sys
import pandas as pd
import pickle
def main():
if len(sys.argv) != 3:
print("Usage: prog input_file output_file")
sys.exit(2)
input_file = sys.argv[1]
output_file = sys.argv[2]
# open with pandas
print("Reading (this will take a while)...", file=sys.stderr, end=' ', flush=True)
data = [pd.read_excel(io=open(input_file, 'rb'), sheet_name=s, header=0)
for s in ['Defect Data', 'ATA CH-SEC', 'MEL Code Data', 'Trax Recurrent Data']]
print("done.", file=sys.stderr)
# write binary
print("Writing...", file=sys.stderr, end=' ', flush=True)
pickle.dump(data, open(output_file, 'wb'))
print("done.", file=sys.stderr)
if __name__ == '__main__':
main()