-
Notifications
You must be signed in to change notification settings - Fork 156
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
Using the csv-parser to get all the values of a specific column #10
Comments
Here's an example for printing the values of a specific column. I agree the documentation is a work in progress.
The documentation for the CSVRow object (auto& row) here (https://vincentlaucsb.github.io/csv-parser/classcsv_1_1CSVRow.html) describes the indexing and value retrieval methods. |
Thanks for the fast reply, I actually saw that yesterday in the documentation and did try it like you wrote, but my IDE gave me some syntax error. Today it worked without any errors, maybe I just needed to restart my IDE.... This brings me to another question. Is this there a more package native way to iterate over each item of some column and being able to change their values? Rather than using this:
If I understood it correctly I can iterate over the items with |
The CSVReader was designed/optimized for reading values. If you want to modify the values, I would just have some custom logic populate another std::vector like you are doing right now. However it is still possible to copy a
which you might find helpful. The reason why you can't modify values is because CSVFields are just thin wrappers over string_views. Of course I could implement some feature to modify the original string, but that'd be very inefficient. It's probably a lot cheaper to just copy what you need and modify that. Previous versions of the CSVReader spit out rows as |
Thanks and good to know. |
Is there a way to iterate over the values of a specific column using a column name (string)? I've searched the documentation but didn't find a clear answer or an example to my question.
The text was updated successfully, but these errors were encountered: