25 virtual void operator()(std::istream &in,
const char *name =
"-") = 0;
53 bool has_header =
false;
55 bool skip_header =
false;
57 std::size_t num_rows = std::numeric_limits<
decltype(
num_rows)>::max();
75 std::istream *in =
nullptr;
76 std::vector<char>
buf;
83 void operator()(std::istream &in,
const char *name)
override;
94 using ConstTypeVisitor::operator();
95 void operator()(Const<ErrorType> &ty)
override;
96 void operator()(Const<NoneType> &ty)
override;
97 void operator()(Const<Boolean> &ty)
override;
98 void operator()(Const<Bitmap> &ty)
override;
99 void operator()(Const<CharacterSequence> &ty)
override;
100 void operator()(Const<Date> &ty)
override;
101 void operator()(Const<DateTime> &ty)
override;
102 void operator()(Const<Numeric> &ty)
override;
103 void operator()(Const<FnType> &ty)
override;
116 return c = in->get();
119 void push() { buf.push_back(c); step(); }
121 bool accept(
char chr) {
if (c == chr) { step();
return true; }
return false; }
124 if (c == config().
quote) {
126 while (c != EOF
and c !=
'\n' and c != config().
quote) { step(); }
127 accept(config().
quote);
129 while (c != EOF
and c !=
'\n' and c != config().delimiter) { step(); }
133 int64_t read_unsigned_int();
and(sizeof(T)==4) U64x1 reinterpret_to_U64(m
std::string escape(char c)
std::string quote(const std::string &str)
Configuration parameters for importing a DSV file.
static Config CSV()
Creates a Config for CSV files, with delimiter, escape, and quote set accordingly to RFC 4180 (see ht...
char delimiter
the delimiter separating cells
char quote
the quotation mark for strings
bool skip_header
whether to ignore the headline (requires has_header = true)
char escape
the character to escape special characters within strings, e.g. \n
bool has_header
whether the first line of the file is a headline describing the columns
std::size_t num_rows
the maximum number of rows to read from the file (may exceed actual number of rows)
A reader for delimiter separated value (DSV) files.
size_t skip_header() const
Tuple tup
intermediate tuple to store values of a row
const Config & config() const
size_t has_header() const
An interface for all readers.
const Table & table
the table to insert the data into
Scheduler::Transaction * transaction
Reader(const Table &table, Diagnostic &diag, Scheduler::Transaction *transaction=nullptr)
virtual void operator()(std::istream &in, const char *name="-")=0
A table is a sorted set of attributes.