-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathformatPhone.py
38 lines (28 loc) · 973 Bytes
/
formatPhone.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
32
33
34
35
36
37
38
#!/usr/bin/env python3
__author__ = 'Natan Elia'
import sys, os
sys.path.append(os.path.abspath('src'))
import Phone
import Util
import time
def main(argv):
if (len(argv) <= 0):
Util.printErr("You have not specified any dirpath.")
Util.printErr("Write something like this: formatPhone.py dirpath [scanParentOnly? True|False]")
return
if (len(argv) > 1):
scanParentOnly = argv[1]
else:
scanParentOnly = False
dirToScan = argv[0]
(f, d) = Util.listFiles(dirToScan, scanParentOnly)
Util.printProcess('Reading JSONs')
jsons = Util.readJSONFiles(dirToScan, f)
print(len(jsons), 'files read.')
fileOut = input('Save CSV filename: ')
Util.printProcess('Converting to single CSV...')
startTime = time.time()
indexMap = Phone.createPhoneIndexMap()
Phone.mapToCSV(jsons, indexMap, fileOut + '.csv')
print('Success! {:f} secs'.format(time.time() - startTime))
main(sys.argv[1:])