Vince's CSV Parser
Loading...
Searching...
No Matches
data_frame_options.hpp
1#pragma once
2
3#include <string>
4
5namespace csv {
7 public:
8 DataFrameOptions() = default;
9
11 enum class DuplicateKeyPolicy {
12 THROW, // Report an error if a duplicate key is encountered
13 OVERWRITE, // Overwrite the existing value with the new value
14 KEEP_FIRST // Ignore the new value and keep the existing value
15 };
16
17 DataFrameOptions& set_duplicate_key_policy(DuplicateKeyPolicy value) {
18 this->duplicate_key_policy = value;
19 return *this;
20 }
21
22 DuplicateKeyPolicy get_duplicate_key_policy() const {
23 return this->duplicate_key_policy;
24 }
25
26 DataFrameOptions& set_key_column(const std::string& value) {
27 this->key_column = value;
28 return *this;
29 }
30
31 const std::string& get_key_column() const {
32 return this->key_column;
33 }
34
35 DataFrameOptions& set_throw_on_missing_key(bool value) {
36 this->throw_on_missing_key = value;
37 return *this;
38 }
39
40 bool get_throw_on_missing_key() const {
41 return this->throw_on_missing_key;
42 }
43
44 private:
45 std::string key_column;
46
47 DuplicateKeyPolicy duplicate_key_policy = DuplicateKeyPolicy::OVERWRITE;
48
50 bool throw_on_missing_key = true;
51 };
52
53}
DuplicateKeyPolicy
Policy for handling duplicate keys when creating a keyed DataFrame.
The all encompassing namespace.