Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -1,27 +1,27 @@
|
|||
import std.stdio, std.array, std.string, std.regex, std.conv,
|
||||
std.algorithm;
|
||||
|
||||
void main() {
|
||||
// works but eats lot of RAM in DMD 2.059
|
||||
//const rxDate = ctRegex!(`^\d\d\d\d-\d\d-\d\d$`);
|
||||
auto rxDate = regex(`^\d\d\d\d-\d\d-\d\d$`);
|
||||
import std.stdio, std.array, std.string, std.regex, std.conv,
|
||||
std.algorithm;
|
||||
|
||||
auto rxDate = `^\d\d\d\d-\d\d-\d\d$`.regex;
|
||||
// Works but eats lot of RAM in DMD 2.064.
|
||||
// auto rxDate = ctRegex!(`^\d\d\d\d-\d\d-\d\d$`);
|
||||
|
||||
int[string] repeatedDates;
|
||||
int goodReadings;
|
||||
foreach (string line; lines(File("readings.txt"))) {
|
||||
foreach (string line; "readings.txt".File.lines) {
|
||||
try {
|
||||
auto parts = line.split();
|
||||
auto parts = line.split;
|
||||
if (parts.length != 49)
|
||||
throw new Exception("Wrong column count");
|
||||
if (match(parts[0], rxDate).empty)
|
||||
if (parts[0].match(rxDate).empty)
|
||||
throw new Exception("Date is wrong");
|
||||
repeatedDates[parts[0]]++;
|
||||
bool noProblem = true;
|
||||
for (int i = 1; i < 48; i += 2) {
|
||||
if (to!int(parts[i + 1]) < 1)
|
||||
if (parts[i + 1].to!int < 1)
|
||||
// don't break loop because it's validation too.
|
||||
noProblem = false;
|
||||
if (!isNumeric(parts[i]))
|
||||
if (!parts[i].isNumeric)
|
||||
throw new Exception("Reading is wrong: "~parts[i]);
|
||||
}
|
||||
if (noProblem)
|
||||
|
|
@ -31,8 +31,7 @@ void main() {
|
|||
}
|
||||
}
|
||||
|
||||
writeln("Duplicated timestamps: ",
|
||||
repeatedDates.keys.filter!(k => repeatedDates[k] > 1)().
|
||||
join(", "));
|
||||
writefln("Duplicated timestamps: %-(%s, %)",
|
||||
repeatedDates.byKey.filter!(k => repeatedDates[k] > 1));
|
||||
writeln("Good reading records: ", goodReadings);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue