readFormattedCSV now is a little more dynamic
This commit is contained in:
parent
294facd71c
commit
6d2a65329d
@ -5,9 +5,12 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class Utilities {
|
||||
public static String makeCSVString(String... rowCells) {
|
||||
@ -28,11 +31,13 @@ public class Utilities {
|
||||
.map((s) -> {
|
||||
String[] spliteration = s.split("\",\"");
|
||||
|
||||
// TODO: If you were to add columns, this would need to be more dynamic then it is
|
||||
return Map.of(
|
||||
Constants.kCSVHeaders[0], spliteration[0].replace("\"", ""),
|
||||
Constants.kCSVHeaders[1], spliteration[1].replace("\"", "")
|
||||
);
|
||||
return IntStream.range(0, spliteration.length)
|
||||
.mapToObj((i) -> Map.of(Constants.kCSVHeaders[i], spliteration[i].replace("\"", "")))
|
||||
.collect(
|
||||
HashMap<String, String>::new,
|
||||
Map::putAll,
|
||||
Map::putAll
|
||||
);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user