Skip to content

Commit 40fa051

Browse files
committed
tweak
1 parent aa05a5a commit 40fa051

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pdf2csv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
def judgeValue(value: str):
99
ret = None
10-
fl = re.compile('[0-9]+\.[0-9]+')
11-
hkl = re.compile('-?[0-9]+\s-?[0-9]+\s-?[0-9]')
10+
fl = re.compile('\d+\.\d+')
11+
hkl = re.compile('-?\d+\s-?\d+\s-?\d')
1212
if fl.match(value):
1313
ret = 'float'
1414
elif hkl.match(value):
@@ -57,7 +57,7 @@ def pdf2csv(pdfpath: str, outpath: str, zeroPadding: bool):
5757
outputName = os.path.join(outpath, basenameWoExt + '.csv')
5858

5959
passExpressions = re.compile(
60-
'^[0-9]+\.[0-9]+$|^[0-9]+$|^-?[0-9]+\s-?[0-9]+\s-?[0-9]+$')
60+
'^\d+\.\d+$|^\d+$|^-?\d+\s-?\d+\s-?\d+$')
6161
values = sub.stdout.decode('utf-8').split('\n')
6262
values = filter(lambda x: passExpressions.match(x), values)
6363
values = list(map(lambda x: [x, judgeValue(x)], values))
@@ -126,8 +126,8 @@ def main():
126126
if args.output != None:
127127
output = args.output[0]
128128
if not os.path.isdir(output):
129-
print(output, ': No such directory.')
130-
return
129+
print('output directory is not exist.')
130+
exit()
131131

132132
for f in inputs:
133133
if os.path.isfile(f):

0 commit comments

Comments
 (0)