LLNL / ygm

Other
31 stars 22 forks source link

CSV Parser Headers #214

Closed steiltre closed 3 months ago

steiltre commented 5 months ago

Adds ability to handle headers in CSV files. Requires allowing ygm::io::line_parser to read the first line of the first file independently and skip over the first line of files in for_all operations.

This functionality is controlled by a ygm::io::csv_parser::read_headers() function that parses the header file to create an internal map from column names to positional indices and puts the csv_parser in a state that will skip over processing the header line when calling for_all. This could also be accomplished by adding an optional flag to the csv_parser constructor, but this would break the symmetry in arguments to the constructors of csv_parser and line_parser.

Additionally, this requires adding a class to handle the CSV lines in a way that items can be accessed through positional indices and column name. The interface of this class is created to match that of the std::vector<csv_field> that was used previously, but the full vector interface is not implemented.

@rogerpearce let me know if this change is consistent with any future changes you have planned for the I/O functionality.