forked from Arks-Layer/PSO2ENPatchCSV
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathpruneempties.py
More file actions
77 lines (60 loc) · 1.73 KB
/
pruneempties.py
File metadata and controls
77 lines (60 loc) · 1.73 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
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
#!/usr/bin/env python3
# coding=utf8
import os
# Get list of empties
empties = os.listdir("Empty")
for file in empties:
filestats = os.stat(os.path.join("Empty", file))
filesize = filestats.st_size
# Not empty, something is up
if filesize != 0:
print("Empty/{name} is NOT empty. (File size: {size} bytes)"
.format(name = file, size = filesize))
empties.remove(file)
print("Press enter to continue.")
input()
# Get filelist data
flist = open("filelist.txt", "r")
flines = flist.readlines()
flist.close()
flist = open("filelist.txt", "w")
# Iterate over lines in filelist
for line in flines:
empty = "no"
for file in empties:
text = file.strip(".csv") + ".text"
if ("," + text) in line:
empty = "yes"
break
if empty == "yes":
print("Removed empty file {name}"
.format(name = text))
else:
flist.write(line)
flist.close()
# Get list of dummies
dummies = os.listdir("Dummy")
print("Before proceeding, please check that " +
"no files in /Dummy are being used.")
print("Press enter to confirm you have made this check, " +
"or press CTRL + C to cancel.")
input()
# Get filelist data
flist = open("filelist.txt", "r")
flines = flist.readlines()
flist.close()
flist = open("filelist.txt", "w")
# Iterate over lines in filelist
for line in flines:
dummy = "no"
for file in dummies:
text = file.strip(".csv") + ".text"
if ("," + text) in line:
dummy = "yes"
break
if dummy == "yes":
print("Removed dummy file {name}"
.format(name = text))
else:
flist.write(line)
flist.close()