CSVImporter
CSVImporter copied to clipboard
Any way to get the column headers before parsing the rest?
I'd like to automatically determine the type of CSV file I'm importing by examining the first line. Is there any way to get the first line as [String]
so that I can test their values (without parsing the whole file)?
Ideally, I could then parameterize the record type as part of the startImport
call, but I can also just instantiate two different importers.
To your question: No, it's currently not possible.
As for the second sentence, I don't understand what you want to do. How is it different than what is possible and described here in the docs?
Right now, I have to parameterize the CSVImporter: CSVImporter<T>
. An alternative would be to parameterize the startImport call: startImport<T>
. But that's not as important as being able to get the header fields out as [String]
with a separate call from startImport()
.