Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 1.25 KB | None | 0 0
  1. import std.stdio, std.file, std.array, std.string, std.algorithm, std.regex;
  2.  
  3. int main(string[] args){
  4.     if(args.length!=2){
  5.         writeln("you're a dim lil' bugger, aren't ya?");
  6.         return -1;
  7.     }
  8.     auto afn=args[1].chomp.matchFirst(regex(r"\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}"));
  9.     if(afn.empty){
  10.         writeln("dafuq you givin me?");
  11.         return -1;
  12.     }
  13.    
  14.     //anemometer
  15.     string htmlfileformat="aurec4_"~afn.hit.translate(['-':'_'])[0..$-2]~"*.html";
  16.     foreach(hfn;dirEntries(".",htmlfileformat,SpanMode.shallow)){
  17.         auto HTMLFile=File(hfn,"r");
  18.         scope(exit) HTMLFile.close();
  19.         //so this is very hacky, <tr><td> 8</td>..data
  20.         foreach(line;HTMLFile.byLine.filter!(x=> x.startsWith(r"<tr><td> 8</td>"))){
  21.             auto mestable=line.split(r"</td><td>").array;
  22.             if(mestable.length>6){
  23.                 write(mestable[6]);
  24.                 return 0;
  25.             }
  26.         }
  27.     }
  28.    
  29.     //excell->csv kmi
  30.     string csvFormat=format("%s%s%s %s",afn.hit[0..4],afn.hit[5..7],afn.hit[8..10],afn.hit[11..13]);
  31.     foreach(cfn;dirEntries(".","*.csv",SpanMode.shallow)){
  32.         auto CSVFile=File(cfn, "r");
  33.         scope(exit) CSVFile.close();
  34.         foreach(result;CSVFile.byLine.map!(curline => curline.split(",").array).filter!(x=>x.length>=4 && x[1]=="MELLE" && x[2]==csvFormat)){
  35.             write(result[4]);
  36.             return 0;
  37.         }
  38.     }
  39.     return -1;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement