-
Notifications
You must be signed in to change notification settings - Fork 1
/
list_original_file_info.py
executable file
·66 lines (45 loc) · 1.53 KB
/
list_original_file_info.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
"""
CBDA validation and training set creation.
This script lists the contents of the Pickle file containing the original
data file information.
"""
import sys
import argparse
import os
import pickle
def define_args(cmd_line_args=None):
"""
Get command line arguments.
"""
parser = argparse.ArgumentParser()
msg = 'The file name of the Pickle file with the original data file'
msg += ' information.'
parser.add_argument('--odfi', '--original-data-file-info',
dest='originalDataFileInfo', help=msg, type=str, \
default=None, required=True)
cmd_line_args = parser.parse_args()
# Check the arguments for validity.
args_ok = True
if not os.path.isfile(cmd_line_args.originalDataFileInfo):
msg = '\nValidation ordinal file "{0}" does not exist.\n'
msg = msg.format(cmd_line_args.originalDataFileInfo)
print(msg)
args_ok = False
if not args_ok:
sys.exit(1)
return cmd_line_args
def print_args(cmd_line_args):
"""
For testing and debugging.
"""
msg = 'cmd_line_args.originalDataFileInfo: {}'
print(msg.format(cmd_line_args.originalDataFileInfo))
# Blank line after all argument lines.
print('')
args = define_args()
#print_args(args)
with open(args.originalDataFileInfo, 'rb') as odfiFile:
(originalLineCount, originalColumnCount) = pickle.load(odfiFile)
print(f'originalLineCount: {originalLineCount}')
print(f'originalColumnCount: {originalColumnCount}')