-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallSplitMergeFiles.py
69 lines (53 loc) · 2.16 KB
/
callSplitMergeFiles.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
67
68
69
###############################################
#### Written By: SATYAKI DE ####
#### Written On: 10-Feb-2019 ####
#### Pandas, Regular Expression, gc ####
#### needs to install in order to run ####
#### this script. ####
#### ####
#### Objective: This script will ####
#### call both the split & merge libraries ####
#### to simulate both the cases using ####
#### large csv files. ####
###############################################
from SplitMerge.clsSplitFiles import clsSplitFiles
from SplitMerge.clsMergeFiles import clsMergeFiles
import re
import platform as pl
import os
def main():
print("Calling the custom Package for large file splitting..")
os_det = pl.system()
print("Running on :", os_det)
###############################################################
###### User Input based on Windows OS ########
###############################################################
srcF = str(input("Please enter the file name with extension:"))
base_name = re.sub(r'[0-9]','', srcF)
srcFileInit = base_name[:-5]
if os_det == "Windows":
subdir = "\\temp\\"
path = os.path.dirname(os.path.realpath(__file__)) + "\\"
else:
subdir = "/temp/"
path = os.path.dirname(os.path.realpath(__file__)) + '/'
###############################################################
###### End Of User Input ######
###############################################################
t = clsSplitFiles(srcF, path, subdir)
ret_val = t.split_files()
if ret_val == 0:
print("Splitting Successful!")
else:
print("Splitting Failure!")
print("-"*30)
print("Finally, Merging small splitted files to make the same big file!")
y = clsMergeFiles(srcFileInit, path)
ret_val1 = y.merge_file()
if ret_val1 == 0:
print("Merge Successful!")
else:
print("Merge Failure!")
print("-"*30)
if __name__ == "__main__":
main()