This repository was archived by the owner on Apr 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnScan.chpl
More file actions
101 lines (91 loc) · 3.67 KB
/
Copy pathnScan.chpl
File metadata and controls
101 lines (91 loc) · 3.67 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use FileSystem;
use IO;
use Time;
config const V : bool=true; // verbose logging
const dSep : string='$D ';
const tSep : string='$T ';
const hSep : string='$H ';
const hTerminate : string="$Ht";
const dInfo : string='$I ';
const dInfoTerminate : string='$It ';
const dRange = 1..8;
const tRange = 1..5;
module charMatches {
var dates : domain(string);
}
var sync1$ : sync bool=true;
proc dateCheck(aFile, ref choice) {
sync1$; // closes line access to other threads
try {
var line : string;
var r = openreader(aFile);
while r.readline(line) {
if line.find(dSep) > 0 {
if line.find(hSep) > 0 {
if choice.contains(line.partition(hSep)[3].partition(hTerminate)[1]) == false {
if line.find(tSep) > 0 && line.find(dInfo) > 0 {
try {
choice += line.partition(dSep)[3][dRange]
+ ',' + line.partition(hSep)[3].partition(hTerminate)[1]
+ ',' + line.partition(tSep)[3][tRange]
+ ',' + line.partition(dInfo)[3].partition(dInfoTerminate)[1]
+ '\n';
} catch {
if V then writeln('error adding date with time, info');
}
}
if line.find(tSep) == 0 && line.find(dInfo) > 0 {
try {
choice += line.partition(dSep)[3][dRange]
+ ',' + line.partition(hSep)[3].partition(hTerminate)[1]
+ ',' + ' '
+ ',' + line.partition(dInfo)[3].partition(dInfoTerminate)[1]
+ '\n';
} catch {
if V then writeln('error adding date with info');
}
}
if line.find(tSep) > 0 && line.find(dInfo) == 0 {
try {
choice += line.partition(dSep)[3][dRange]
+ ',' + line.partition(hSep)[3].partition(hTerminate)[1]
+ ',' + line.partition(tSep)[3][tRange]
+ '\n';
} catch {
if V then writeln('error adding date with time');
}
}
if line.find(tSep) == 0 && line.find(dInfo) == 0 {
try {
choice += line.partition(dSep)[3][dRange]
+ ',' + line.partition(hSep)[3].partition(hTerminate)[1]
+ '\n';
} catch {
if V then writeln('error adding date');
}
}
}
}
}
}
r.close();
} catch {
if V then writeln("caught error iterating");
}
sync1$ = true;
}
coforall folder in walkdirs('check/') {
for file in findfiles(folder) {
dateCheck(file, charMatches.dates);
}
}
// write information to files
proc WriteAll(N : string, content) {
var OFile = open(N, iomode.cw);
var Ochann = OFile.writer();
Ochann.write(content.strip('{'));
Ochann.close();
OFile.close();
}
// space seperated:
WriteAll("dates.csv", charMatches.dates);