Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling files with optional header lines? #10

Closed
intendo opened this issue Dec 8, 2015 · 1 comment
Closed

Handling files with optional header lines? #10

intendo opened this issue Dec 8, 2015 · 1 comment

Comments

@intendo
Copy link

intendo commented Dec 8, 2015

What is the best way to write the code to handle the situation where you get a file with the correct format but the header line is missing?

We get the same data from multiple sources and some sources provide a header and some do not.

@ben-strasser
Copy link
Owner

Hi,

use the

void set_header(some_string_type col_name1, some_string_type col_name2, ...);

function instead of parse_header. The documentation states:

The |set_header| method does /not/ read any input. Use it if the file
does not have any header. Obviously it is impossible to rearrange
columns or check for their availability when using it. The order in
the file and in the program must match when using |set_header|.

Essentially you give the first column the first parameter as name, the
second column the second parameter, etc. The column names are only used
to format error messages. The number of parameters is used to check that
the number of column matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants