Skip to content

Instantly share code, notes, and snippets.

@Riduidel
Last active April 3, 2019 19:50
Show Gist options
  • Save Riduidel/d8ddfbe1c4944cc3e941901a89345592 to your computer and use it in GitHub Desktop.
Save Riduidel/d8ddfbe1c4944cc3e941901a89345592 to your computer and use it in GitHub Desktop.
data munging
public class DataMunging {
public static void main(String[] args) throws IOException {
System.out.println(
Files.lines(Paths.get("weather.dat"))
.map(line -> line.trim())
.map(line -> line.split(" +"))
.filter(elements -> elements[0].matches("[0-9\\*]+"))
.map(elements -> new AbstractMap.SimpleEntry<>(elements[0],
Integer.parseInt(elements[1].replace("*", "")) - Integer.parseInt(elements[2].replace("*", "")
)))
.min((e1, e2) -> e1.getValue()-e2.getValue())
.map(e -> e.getKey())
.get()
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment