Class CsvToQRecordAdapter
java.lang.Object
com.kingsrook.qqq.backend.core.adapters.CsvToQRecordAdapter
Adapter class to convert a CSV string into a list of QRecords.
Based on which method is called, can either take a pipe, and stream records
into it - or return a list of all records from the file. Either way, at this
time, the full CSV string is read invalid input: '&' parsed - a future optimization might read
the CSV content from a stream as well.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildRecordsFromCsv
(RecordPipe recordPipe, String csv, QTableMetaData table, AbstractQFieldMapping<?> mapping, Consumer<QRecord> recordCustomizer) stream records from a CSV String into a RecordPipe, for a given table, optionally using a given mapping.void
buildRecordsFromCsv
(CsvToQRecordAdapter.InputWrapper inputWrapper) convert a CSV String into a List of QRecords, for a given table, optionally using a given mapping.buildRecordsFromCsv
(String csv, QTableMetaData table, AbstractQFieldMapping<?> mapping) convert a CSV String into a List of QRecords, for a given table, optionally using a given mapping.Getter for recordList - note - only is valid if you don't supply a pipe in the input.makeHeadersUnique
(List<String> headers) For a list of headers, if any duplicates are found, add a numeric suffix to the duplicates.
-
Constructor Details
-
CsvToQRecordAdapter
public CsvToQRecordAdapter()
-
-
Method Details
-
buildRecordsFromCsv
convert a CSV String into a List of QRecords, for a given table, optionally using a given mapping. todo - meta-data validation, type handling- Throws:
QException
-
makeHeadersUnique
For a list of headers, if any duplicates are found, add a numeric suffix to the duplicates. So this header row: A,B,C,C,C Would become: A,B,C,C 2,C 3 See unit test for more scenarios - some of which we do not handle well yet, such as "C 2, C, C 3" -
getRecordList