Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1008740 // Simplify ipToCountry.csv

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1566L/11K/37K).

1  
!7
2  
3  
p {
4  
  File in = new File("/home/stefan/dev/ip-to-country.csv");
5  
  long last = 0;
6  
  new StringBuilder buf;
7  
  for (S s : linesFromReader(utf8BufferedReader(in))) {
8  
    L<S> l = tok_splitAtComma_unquote(s);
9  
    if (l(l) < 3) continue;
10  
    long start = ipToInt(first(l));
11  
    S country = last(l);
12  
    S line = (start-last) + " " + country;
13  
    print(line);
14  
    buf.append(line + "\n");
15  
    last = start;
16  
  }
17  
  File out = new File(f2s(in) + ".short.gz");
18  
  saveGZTextFile(out, str(buf));
19  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008740
Snippet name: Simplify ipToCountry.csv
Eternal ID of this version: #1008740/4
Text MD5: 890070c3820a101f71a0f258685b6c16
Transpilation MD5: 360dff04d904b4e6022c2569a26f8c6a
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-31 13:38:32
Source code size: 506 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 537 / 707
Version history: 3 change(s)
Referenced in: [show references]