mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-07-15 14:59:19 +08:00
Adding option to for user-defined NULL token in CSV output (not sure if it should be escaped..)
This commit is contained in:
parent
bd88fb7d43
commit
e85c3438ec
9
src/util/mdb-export.c
Normal file → Executable file
9
src/util/mdb-export.c
Normal file → Executable file
@ -93,6 +93,7 @@ main(int argc, char **argv)
|
||||
char *date_fmt = NULL;
|
||||
char *namespace = NULL;
|
||||
char *str_bin_mode = NULL;
|
||||
char *null_text = NULL;
|
||||
int bin_mode = MDB_BINEXPORT_RAW;
|
||||
char *value;
|
||||
size_t length;
|
||||
@ -107,6 +108,7 @@ main(int argc, char **argv)
|
||||
{ "date_format", 'D', 0, G_OPTION_ARG_STRING, &date_fmt, "Set the date format (see strftime(3) for details)", "format"},
|
||||
{ "escape", 'X', 0, G_OPTION_ARG_STRING, &escape_char, "Use <char> to escape quoted characters within a field. Default is doubling.", "format"},
|
||||
{ "namespace", 'N', 0, G_OPTION_ARG_STRING, &namespace, "Prefix identifiers with namespace", "namespace"},
|
||||
{ "null", '0', 0, G_OPTION_ARG_STRING, &null_text, "Use <char> to represent a NULL value", "char"},
|
||||
{ "bin", 'b', 0, G_OPTION_ARG_STRING, &str_bin_mode, "Binary export mode", "strip|raw|octal"},
|
||||
{ NULL },
|
||||
};
|
||||
@ -153,6 +155,11 @@ main(int argc, char **argv)
|
||||
|
||||
if (date_fmt)
|
||||
mdb_set_date_fmt(date_fmt);
|
||||
|
||||
if (null_text)
|
||||
null_text = escapes(null_text);
|
||||
else
|
||||
null_text = g_strdup("");
|
||||
|
||||
if (str_bin_mode) {
|
||||
if (!strcmp(str_bin_mode, "strip"))
|
||||
@ -233,6 +240,8 @@ main(int argc, char **argv)
|
||||
/* Don't quote NULLs */
|
||||
if (insert_dialect)
|
||||
fputs("NULL", outfile);
|
||||
else
|
||||
fputs(null_text, outfile);
|
||||
} else {
|
||||
if (col->col_type == MDB_OLE) {
|
||||
value = mdb_ole_read_full(mdb, col, &length);
|
||||
|
Loading…
Reference in New Issue
Block a user