-
Notifications
You must be signed in to change notification settings - Fork 10
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
General CSV reader #152
General CSV reader #152
Conversation
|
Syntax checkNo syntax error, good job! 💜 |
Coverage after merging csv_reader into main will be
Coverage Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use this to parse the vtest files as well?
I just merged #151 so I'll have to rebase this one.
Mechanistically yes. Though right now I rely on the glob pattern |
I think this has been abandoned? |
We can revive this if needed. |
This PR adds a header-only CSV reader from https://github.com/vincentlaucsb/csv-parser. I didn't include the library as a cmake subdirectory because it's folder hierarchy makes install very difficult. Since it is MIT license, I just copied the single header file into our contrib folder.
The primary entry point for CSV reader is
Sequence
. It is designed as a sequence reader to retrieve a single column from a CSV file. Design details are included in the class docstring. It's zero-effort for developers to opt-in to use a CSV to fill a vector by changingoptions.set<std::vector<Real>>("foo");
to
options.set<Sequence<Real>>("foo");
With the above code, users are able to specify the sequence in one of three ways:
foo = '1 2 3 4 5 6'
<-- equivalent to parsingstd::vector<Real>
foo = 'my.csv:key'
<-- we try to readmy.csv
and fill the vector with the CSV column with namekey
.foo = 'my.csv:[2]'
<-- we try to readmy.csv
and fill the vector with the CSV column with index2
.Other changes are just for expanding parser support and test coverage.
This is the (big) first step towards @sapitts 's request of defining irradiation eigenstrain using a CSV file.
close #154