getHeaders in CsvReader #146
Closed
xavier-figueroa
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
You can call getHeader() or getFieldsAsMap() on NamedCsvRecord records. Example: Path file = Path.of("test.csv");
try (CsvReader<NamedCsvRecord> csv = CsvReader.builder().ofNamedCsvRecord(file)) {
for (NamedCsvRecord rec : csv) {
List<String> header = rec.getHeader();
Map<String, String> fieldMap = rec.getFieldsAsMap();
// ...
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
Thanks for this additional info. Currently it is not possible to access the header of a file that contains nothing more than the header via NamedCsvRecord. I transferred this to #147. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I havent seen any easy way to get the existing headers for a file. It would be great to get a list/map with all the headers (first row)
Beta Was this translation helpful? Give feedback.
All reactions