Skip to content

Instantly share code, notes, and snippets.

@miho
Last active June 25, 2017 13:48
Show Gist options
  • Save miho/70400af857b4f697dcc5dd291018ffcf to your computer and use it in GitHub Desktop.
Save miho/70400af857b4f697dcc5dd291018ffcf to your computer and use it in GitHub Desktop.
package eu.mihosoft.vrl.user;
@ComponentInfo(name="CSVReader", category="Custom")
public class CSVReader implements java.io.Serializable {
private static final long serialVersionUID=1L;
// ---- add your code here -----
public void plot(
@ParamInfo(name="CSV File", style="load-dialog", options="") File input,
@ParamInfo(name="Separator", options="value=\",\"") String sep,
@ParamInfo(name="Column", style="default", options="value=0") int col) {
input.eachLine{l->
l = l.trim();
String[] numbers = l.split(sep);
String stringVal = numbers[col];
double value = java.lang.Double.parseDouble(stringVal);
// do something with the value
println("VAL: " + value)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment