1
|
|
|
import getopt |
2
|
|
|
import sys |
3
|
|
|
import time |
4
|
|
|
|
5
|
|
|
from TableauHyperApiExtraLogic import TableauHyperApiExtraLogic as _cls_thael |
6
|
|
|
from CommandLineArgumentsHandling import CommandLineArgumentsHandling as _cls_clah |
7
|
|
|
from datetime import timedelta |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
def fn_command_line_argument_interpretation(argv): |
11
|
|
|
print('#'*120) |
12
|
|
|
input_file = '' |
13
|
|
|
csv_field_separator = ',' |
14
|
|
|
output_file = '' |
15
|
|
|
verbose = False |
16
|
|
|
_cls_clah.fn_load_configuration(_cls_clah) |
17
|
|
|
help_feedback = __file__ + _cls_clah.fn_build_combined_options(_cls_clah) |
18
|
|
|
try: |
19
|
|
|
opts, args = getopt.getopt(argv, |
20
|
|
|
_cls_clah.fn_build_short_options(_cls_clah), |
21
|
|
|
_cls_clah.fn_build_long_options(_cls_clah)) |
22
|
|
|
except getopt.GetoptError: |
23
|
|
|
print(help_feedback) |
24
|
|
|
sys.exit(2) |
25
|
|
|
for opt, arg in opts: |
26
|
|
|
if opt == '-h': |
27
|
|
|
print(help_feedback) |
28
|
|
|
sys.exit() |
29
|
|
|
elif opt in ("-i", "--input-file"): |
30
|
|
|
input_file = arg |
31
|
|
|
elif opt in ("-s", "--csv-field-separator"): |
32
|
|
|
csv_field_separator = arg |
33
|
|
|
elif opt in ("-o", "--output-file"): |
34
|
|
|
output_file = arg |
35
|
|
|
elif opt in ("-v", "--verbose"): |
36
|
|
|
verbose = True |
37
|
|
|
else: |
38
|
|
|
assert False, "unhandled option" |
39
|
|
|
_cls_clah.fn_assess_option(_cls_clah, 'i', input_file) |
40
|
|
|
print('CSV field separator is "' + csv_field_separator + '"') |
41
|
|
|
_cls_clah.fn_assess_option(_cls_clah, 'o', output_file) |
42
|
|
|
print('#'*120) |
43
|
|
|
_cls_thael.fn_run_create_hyper_file_from_csv(_cls_thael, |
44
|
|
|
input_file, |
45
|
|
|
csv_field_separator, |
46
|
|
|
output_file, |
47
|
|
|
verbose) |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
if __name__ == '__main__': |
51
|
|
|
# marking the start of performance measuring (in nanoseconds) |
52
|
|
|
performance_start = time.perf_counter_ns() |
53
|
|
|
fn_command_line_argument_interpretation(sys.argv[1:]) |
54
|
|
|
# marking the end of performance measuring (in nanoseconds) |
55
|
|
|
performance_finish = time.perf_counter_ns() |
56
|
|
|
performance_timed = timedelta(microseconds=(performance_finish - performance_start)/1000) |
57
|
|
|
print("This script has been executed in " + format(performance_timed) + ' seconds') |
58
|
|
|
|