CSVImporter icon indicating copy to clipboard operation
CSVImporter copied to clipboard

Any way to get the column headers before parsing the rest?

Open JetForMe opened this issue 6 years ago • 2 comments

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.

JetForMe avatar Mar 29 '18 01:03 JetForMe

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?

Jeehut avatar Mar 31 '18 00:03 Jeehut

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().

JetForMe avatar Mar 31 '18 00:03 JetForMe