-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplitFile.py
More file actions
43 lines (36 loc) · 1.09 KB
/
SplitFile.py
File metadata and controls
43 lines (36 loc) · 1.09 KB
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
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @FileName :Test.py
# @Software PyCharm
from datetime import datetime
def Main():
#目标路径
target_dir = ''
#资源路径
source_dir = ''
flag =0
#文件名
name =1
#存放数据
dataList =[]
print("开始。。。。。")
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
with open(source_dir, 'r') as f_source:
for line in f_source:
flag += 1
dataList.append(line)
if flag == 1993:
with open(target_dir + "sql_list_" + str(name) + ".sql", 'w+') as f_target:
for data in dataList:
f_target.write(data)
name += 1
flag = 0
dataList = []
# 处理最后一批行数少于指定行数
with open(target_dir + "sql_" + str(name) + ".sql", 'w+') as f_target:
for data in dataList:
f_target.write(data)
print("完成。。。。。")
print(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
if __name__ == "__main__":
Main()