From e85c3438ec6680cce2d546143a6c80efba1111b0 Mon Sep 17 00:00:00 2001 From: Joshua Short Date: Mon, 1 Aug 2016 09:11:21 -0700 Subject: [PATCH] Adding option to for user-defined NULL token in CSV output (not sure if it should be escaped..) --- src/util/mdb-export.c | 9 +++++++++ 1 file changed, 9 insertions(+) mode change 100644 => 100755 src/util/mdb-export.c diff --git a/src/util/mdb-export.c b/src/util/mdb-export.c old mode 100644 new mode 100755 index a25b7a4..dc10545 --- a/src/util/mdb-export.c +++ b/src/util/mdb-export.c @@ -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 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 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);