-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge_files.py
158 lines (108 loc) · 4.65 KB
/
merge_files.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import glob, os
y2015 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\HMR\\2015"
y2016 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\HMR\\2015"
y2017 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\HMR\\2015"
TN_ma_f1_2015 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\TMR1\\2015"
TN_ma_f1_2016 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\TMR1\\2016"
TN_ma_f1_2017 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\TMR1\\2017"
TN_ma_f1a_2015 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\TMR1a\\2015"
TN_ma_f1a_2016 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\TMR1a\\2016"
TN_ma_f1a_2017 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\TMR1a\\2017"
CMR_2015 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\CMR\\2015"
CMR_2016 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\CMR\\2016"
CMR_2017 = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\CMR\\2017"
mergedFolder = "C:\\Users\\username\\PycharmProjects\\TNregi_Scrape\\"
print('merging 2015.....')
all_files = glob.glob(os.path.join(y2015, "RECORDS_*.csv"))
with open("Merged 2015 v2.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged 2015 !')
print('merging 2016.....')
all_files = glob.glob(os.path.join(y2016, "RECORDS_*.csv"))
with open("Merged 2016 v2.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged 2016 !')
print('merging 2017.....')
all_files = glob.glob(os.path.join(y2017, "RECORDS_*.csv"))
with open("Merged 2017 v2.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged 2017 !')
# TAMILNADU MARRIAGE FORM I
print('merging TN_ma_f1 2015.')
all_files = glob.glob(os.path.join(TN_ma_f1_2015, "RECORDS_*.csv"))
with open("Merged 2015 TN_ma_f1_2015.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged TN_ma_f1 2015 !')
print('merging TN_ma_f1 2016.')
all_files = glob.glob(os.path.join(TN_ma_f1_2016, "RECORDS_*.csv"))
with open("Merged 2016 TN_ma_f1_2016.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged TN_ma_f1 2016 !')
print('merging TN_ma_f1 2017.')
all_files = glob.glob(os.path.join(TN_ma_f1_2017, "RECORDS_*.csv"))
with open("Merged 2017 TN_ma_f1_2017.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged TN_ma_f1 2017 !')
# TAMILNADU MARRIAGE FORM Ia
print('merging TN_ma_f1a_2015 .')
all_files = glob.glob(os.path.join(TN_ma_f1a_2015, "RECORDS_*.csv"))
with open("Merged 2015 TN_ma_f1a_2015.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged TN_ma_f1a 2015 !')
print('merging TN_ma_f1a 2016.')
all_files = glob.glob(os.path.join(TN_ma_f1a_2016, "RECORDS_*.csv"))
with open("Merged 2016 TN_ma_f1a_2016.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged TN_ma_f1a 2016 !')
print('merging TN_ma_f1a 2017.')
all_files = glob.glob(os.path.join(TN_ma_f1a_2017, "RECORDS_*.csv"))
with open("Merged 2017 TN_ma_f1a_2017.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged TN_ma_f1a 2017 !')
# CHRISTIAN MARRIAGE
print('merging CMR 2015.')
all_files = glob.glob(os.path.join(CMR_2015, "RECORDS_*.csv"))
with open("Merged 2015 CMR_2015.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged CMR 2015 !')
print('merging CMR 2016.')
all_files = glob.glob(os.path.join(CMR_2016, "RECORDS_*.csv"))
with open("Merged 2016 CMR_2016.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged CMR 2016 !')
print('merging CMR 2017.')
all_files = glob.glob(os.path.join(CMR_2017, "RECORDS_*.csv"))
with open("Merged 2017 CMR_2017.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged CMR 2017 !')
print('MERGING All.....')
all_files = glob.glob(os.path.join(mergedFolder, "Merged 20*.csv"))
with open("MAR REC 2015-17.csv", "wb") as outfile:
for f in all_files:
with open(f, "rb") as infile:
outfile.write(infile.read())
print('merged All !')