Merge branch 'csv-empty-line'

This commit is contained in:
phact 2020-05-18 10:59:12 -04:00
commit b3c185c88f
6 changed files with 22 additions and 13 deletions

View File

@ -52,7 +52,9 @@ public class ModuloCSVLineToUUID implements LongFunction<UUID> {
CSVParser csvp = NBIO.readFileCSV(filename);
int column = csvp.getHeaderMap().get(fieldname);
for (CSVRecord strings : csvp) {
lines.add(strings.get(column));
if (strings.get(column) != null) {
lines.add(strings.get(column));
}
}
}

View File

@ -78,9 +78,11 @@ public class CSVFrequencySampler implements LongFunction<String> {
CSVParser csvdata = NBIO.readFileCSV(filename);
Frequency freq = new Frequency();
for (CSVRecord csvdatum : csvdata) {
String value = csvdatum.get(columnName);
freq.addValue(value);
values.add(value);
if (csvdatum.get(columnName) != null) {
String value = csvdatum.get(columnName);
freq.addValue(value);
values.add(value);
}
}
int i = 0;
for (String value : values) {

View File

@ -81,9 +81,11 @@ public class DelimFrequencySampler implements LongFunction<String> {
CSVParser csvdata = NBIO.readFileDelimCSV(filename,delimiter);
Frequency freq = new Frequency();
for (CSVRecord csvdatum : csvdata) {
String value = csvdatum.get(columnName);
freq.addValue(value);
values.add(value);
if (csvdatum.get(columnName) != null) {
String value = csvdatum.get(columnName);
freq.addValue(value);
values.add(value);
}
}
int i = 0;
for (String value : values) {

View File

@ -76,10 +76,12 @@ public class WeightedStringsFromCSV implements LongFunction<String> {
}
CSVParser csvdata = NBIO.readFileCSV(filename);
for (CSVRecord csvdatum : csvdata) {
String value = csvdatum.get(valueColumn);
values.add(value);
String weight = csvdatum.get(weightColumn);
events.add(new EvProbD(values.size()-1,Double.valueOf(weight)));
if (csvdatum.get(valueColumn) != null && csvdatum.get(weightColumn) != null) {
String value = csvdatum.get(valueColumn);
values.add(value);
String weight = csvdatum.get(weightColumn);
events.add(new EvProbD(values.size() - 1, Double.valueOf(weight)));
}
}
}
sampler = new AliasSamplerDoubleInt(events);

View File

@ -60,7 +60,9 @@ public class ModuloCSVLineToString implements LongFunction<String> {
}
for (CSVRecord strings : csvp) {
lines.add(strings.get(column));
if (strings.get(column) != null) {
lines.add(strings.get(column));
}
}
}

View File

@ -240,4 +240,3 @@ EH,Western Sahara
YE,Yemen
ZM,Zambia
ZW,Zimbabwe

1 COUNTRY_CODE COUNTRY_NAME
240 YE Yemen
241 ZM Zambia
242 ZW Zimbabwe