]> WPIA git - gigi.git/blob - util/club/wpia/gigi/util/HighFinancialValueFetcherAlexa.java
Merge "upd: remove 'browser install'"
[gigi.git] / util / club / wpia / gigi / util / HighFinancialValueFetcherAlexa.java
1 package club.wpia.gigi.util;
2
3 import java.io.File;
4 import java.io.PrintWriter;
5
6 public class HighFinancialValueFetcherAlexa extends HighFinancialValueFetcher {
7
8     public HighFinancialValueFetcherAlexa(File f, int max) {
9         super(f, max, "https://s3.amazonaws.com/alexa-static/top-1m.csv.zip");
10     }
11
12     @Override
13     public void handle(String line, PrintWriter fos) {
14         String[] parts = line.split(",");
15
16         // Assert that the value before the "," is an integer
17         try {
18             if (Integer.parseInt(parts[0]) < 1) {
19                 throw new NumberFormatException("We expect a number greater then zero for the first column.");
20             }
21         } catch (NumberFormatException nfe) {
22             // Bail on lines with invalid first field
23             throw new Error("Invalid format of first column.", nfe);
24         }
25
26         emit(fos, parts[1]);
27         System.out.println(parts[1]);
28     }
29
30 }