Skip to content

multiple headers #128

Answered by MarkPflug
rychlym asked this question in Q&A
May 31, 2022 · 8 comments · 12 replies
Discussion options

You must be logged in to vote

Without knowing more about the shape of your file, here are a couple things you can try.

You can set CsvDataReaderOptions.ResultSetMode = ResultSetMode.MultiResult. This will cause the reader to consider all changes in the number of columns to be the start of a new dataset. You would call Read in a loop, like normal, but then you would need to call NextResult to start reading the next table. This only works if the number of columns in the tables is different though, or there is an empty line that separates them.

Another option would be to read the header comment and parse the row info. You can do this manually on the TextReader before passing to CsvDataReader.Create, or you can use the Cs…

Replies: 8 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by rychlym
Comment options

You must be logged in to vote
3 replies
@MarkPflug
Comment options

@rychlym
Comment options

@MarkPflug
Comment options

Comment options

You must be logged in to vote
1 reply
@MarkPflug
Comment options

Comment options

You must be logged in to vote
1 reply
@MarkPflug
Comment options

Comment options

You must be logged in to vote
1 reply
@MarkPflug
Comment options

Comment options

You must be logged in to vote
1 reply
@MarkPflug
Comment options

Comment options

You must be logged in to vote
3 replies
@MarkPflug
Comment options

@plsft
Comment options

@MarkPflug
Comment options

Comment options

You must be logged in to vote
2 replies
@MarkPflug
Comment options

@plsft
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants