CsvLinesToMaps

See javadoc - uk.gov.gchq.koryphe.impl.function.CsvLinesToMaps

Available since Koryphe version 1.8.0

Parses CSV lines into Maps

Examples

Cst to map deliminator

Java
JSON
Full JSON
Python
final CsvLinesToMaps function = new CsvLinesToMaps()
        .header("header1", "header2", "header3")
        .firstRow(1)
        .delimiter('|');
{
  "class" : "CsvLinesToMaps",
  "header" : [ "header1", "header2", "header3" ],
  "firstRow" : 1,
  "delimiter" : "|"
}
{
  "class" : "uk.gov.gchq.koryphe.impl.function.CsvLinesToMaps",
  "header" : [ "header1", "header2", "header3" ],
  "firstRow" : 1,
  "delimiter" : "|"
}
g.CsvLinesToMaps( 
  delimiter="|", 
  header=[ 
    "header1", 
    "header2", 
    "header3" 
  ], 
  first_row=1 
)

Input type:

java.lang.Iterable

Example inputs:

Input TypeInputResult TypeResult
java.util.Arrays$ArrayList[header1|header2|header3, value1|value2|value3]uk.gov.gchq.koryphe.util.IterableUtil$MappedIterable[{header3=value3, header2=value2, header1=value1}]
java.util.Arrays$ArrayList[header1|header2|header3, value1||value3]uk.gov.gchq.koryphe.util.IterableUtil$MappedIterable[{header3=value3, header2=, header1=value1}]
java.util.Arrays$ArrayList[header1|header2|header3, value1|value2]IllegalArgumentException: CSV has 2 columns, but there are 3 provided column names
java.util.Arrays$ArrayList[header1||header3, value1|value2|value3]uk.gov.gchq.koryphe.util.IterableUtil$MappedIterable[{header3=value3, header2=value2, header1=value1}]
java.util.Arrays$ArrayList[header1|header2, value1|value2|value3]uk.gov.gchq.koryphe.util.IterableUtil$MappedIterable[{header3=value3, header2=value2, header1=value1}]
java.util.Arrays$ArrayList[header1|header2|header3, value1|value2|value3, value4|value5|value6]uk.gov.gchq.koryphe.util.IterableUtil$MappedIterable[{header3=value3, header2=value2, header1=value1}, {header3=value6, header2=value5, header1=value4}]
java.util.Arrays$ArrayList[header1|header2|header3, , value4|value5|value6]NoSuchElementException: No more CSV records available
java.util.Arrays$ArrayList[header1|header2|header3, null, value4|value5|value6]NullPointerException: null
java.util.Arrays$ArrayList[value1|value2|value3, value4|value5|value6]uk.gov.gchq.koryphe.util.IterableUtil$MappedIterable[{header3=value3, header2=value2, header1=value1}, {header3=value6, header2=value5, header1=value4}]
java.util.Arrays$ArrayList[null, value1|value2|value3, value4|value5|value6]uk.gov.gchq.koryphe.util.IterableUtil$MappedIterable[{header3=value3, header2=value2, header1=value1}, {header3=value6, header2=value5, header1=value4}]

results matching ""

    No results matching ""