Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio, std.file, std.array, std.string, std.algorithm, std.regex;
- int main(string[] args){
- if(args.length!=2){
- writeln("you're a dim lil' bugger, aren't ya?");
- return -1;
- }
- auto afn=args[1].chomp.matchFirst(regex(r"\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}"));
- if(afn.empty){
- writeln("dafuq you givin me?");
- return -1;
- }
- //anemometer
- string htmlfileformat="aurec4_"~afn.hit.translate(['-':'_'])[0..$-2]~"*.html";
- foreach(hfn;dirEntries(".",htmlfileformat,SpanMode.shallow)){
- auto HTMLFile=File(hfn,"r");
- scope(exit) HTMLFile.close();
- //so this is very hacky, <tr><td> 8</td>..data
- foreach(line;HTMLFile.byLine.filter!(x=> x.startsWith(r"<tr><td> 8</td>"))){
- auto mestable=line.split(r"</td><td>").array;
- if(mestable.length>6){
- write(mestable[6]);
- return 0;
- }
- }
- }
- //excell->csv kmi
- string csvFormat=format("%s%s%s %s",afn.hit[0..4],afn.hit[5..7],afn.hit[8..10],afn.hit[11..13]);
- foreach(cfn;dirEntries(".","*.csv",SpanMode.shallow)){
- auto CSVFile=File(cfn, "r");
- scope(exit) CSVFile.close();
- foreach(result;CSVFile.byLine.map!(curline => curline.split(",").array).filter!(x=>x.length>=4 && x[1]=="MELLE" && x[2]==csvFormat)){
- write(result[4]);
- return 0;
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement