@@ -104,6 +104,9 @@ In addition to the [Features & Examples](#features--examples) below, a [fully-fl
104104If you use this library for work, please [become a sponsor](https://github.com/sponsors/vincentlaucsb). Your donation
105105will fund continued maintenance and development of the project.
106106
107+ Shameless plug: If you like this library, check out my side project
108+ [experiencer](https://github.com/vincentlaucsb/experiencer) — a WYSIWYG resume editor with clean HTML/CSS output.
109+
107110## Integration
108111
109112This library was developed with Microsoft Visual Studio and is compatible with >g++ 7.5 and clang.
@@ -438,9 +441,13 @@ using namespace csv;
438441
439442...
440443
441- // Create a DataFrame keyed by employee ID
444+ // Shortest form: pass a filename directly with DataFrameOptions
445+ DataFrame<int > df ("employees.csv",
446+ DataFrameOptions().set_key_column("employee_id"));
447+
448+ // Or construct from an existing CSVReader (e.g. when you need a custom format)
442449CSVReader reader("employees.csv");
443- DataFrame<int > df (reader, "employee_id");
450+ DataFrame<int > df2 (reader, "employee_id");
444451
445452// O(1) lookups by key
446453auto salary = df[ 12345] [ "salary" ] .get<double >();
@@ -455,9 +462,23 @@ if (df.contains(99999)) {
455462}
456463```
457464
465+ **Using DataFrameOptions for Fine-Grained Control**
466+ ```cpp
467+ // Configure key column, duplicate-key policy, and missing-key behaviour
468+ DataFrameOptions opts;
469+ opts.set_key_column("employee_id")
470+ .set_duplicate_key_policy(
471+ DataFrameOptions::DuplicateKeyPolicy::KEEP_FIRST) // or OVERWRITE / THROW
472+ .set_throw_on_missing_key(false); // silently skip rows with no key value
473+
474+ DataFrame<int> df("employees.csv", opts);
475+ ```
476+
458477** Creating a DataFrame with a Custom Key Function**
459478``` cpp
460- // Create a composite key from two columns
479+ CSVReader reader ("employees.csv");
480+
481+ // Build a composite key from two columns
461482auto make_key = [ ] (const CSVRow& row) {
462483 return row[ "first_name"] .get< std::string > () + "_ " +
463484 row[ "last_name"] .get< std::string > ();
@@ -504,6 +525,7 @@ auto by_salary_range = df.group_by([](const CSVRow& row) {
504525```
505526
506527** Writing Back to CSV**
528+
507529Each ` DataFrameRow ` has an implicit conversion to ` std::vector<std::string> ` ,
508530which is convenient when using ` CSVWriter ` .
509531
0 commit comments