Produces an error message for a dialect sniffing error.
175978 {
175979 std::ostringstream error;
175980
175981 error << "Error when sniffing file \"" << options.file_path << "\"." << '\n';
175982
175983 error << "It was not possible to automatically detect the CSV parsing ";
175984 if (type_detection) {
175985 error << "types" << '\n';
175986 } else {
175987 error << "dialect" << '\n';
175988 }
175989
175990
175991 error << "The search space used was:" << '\n';
175992 error << search_space;
175993 error << "Encoding: " << options.encoding << '\n';
175994
175995 error << "Possible fixes:" << '\n';
175996
175997
175998 if (options.dialect_options.state_machine_options.strict_mode.GetValue()) {
175999 error << "* Disable the parser's strict mode (strict_mode=false) to allow reading rows that do not comply with "
176000 "the CSV standard."
176001 << '\n';
176002 }
176003 if (options.columns_set) {
176004
176005 error << "* Columns are set as: \"" << set_columns.ToString() << "\", and they contain: " << set_columns.Size()
176006 << " columns. It does not match the number of columns found by the sniffer: " << max_columns_found << "."
176007 << " Verify the columns parameter is correctly set." << '\n';
176008 }
176009
176010 error << "* Make sure you are using the correct file encoding. If not, set it (e.g., encoding = 'utf-16')." << '\n';
176011
176012
176013 if (!options.dialect_options.state_machine_options.delimiter.IsSetByUser()) {
176014 error << "* Set delimiter (e.g., delim=\',\')" << '\n';
176015 } else {
176016 error << "* Delimiter is set to \'" << options.dialect_options.state_machine_options.delimiter.GetValue()
176017 << "\'. Consider unsetting it." << '\n';
176018 }
176019
176020 if (!options.dialect_options.state_machine_options.quote.IsSetByUser()) {
176021 error << "* Set quote (e.g., quote=\'\"\')" << '\n';
176022 } else {
176023 error << "* Quote is set to \'" << options.dialect_options.state_machine_options.quote.GetValue()
176024 << "\'. Consider unsetting it." << '\n';
176025 }
176026
176027 if (!options.dialect_options.state_machine_options.escape.IsSetByUser()) {
176028 error << "* Set escape (e.g., escape=\'\"\')" << '\n';
176029 } else {
176030 error << "* Escape is set to \'" << options.dialect_options.state_machine_options.escape.GetValue()
176031 << "\'. Consider unsetting it." << '\n';
176032 }
176033
176034 if (!options.dialect_options.state_machine_options.comment.IsSetByUser()) {
176035 error << "* Set comment (e.g., comment=\'#\')" << '\n';
176036 } else {
176037 error << "* Comment is set to \'" << options.dialect_options.state_machine_options.comment.GetValue()
176038 << "\'. Consider unsetting it." << '\n';
176039 }
176040
176041 if (!options.dialect_options.skip_rows.IsSetByUser()) {
176042 error << "* Set skip (skip=${n}) to skip ${n} lines at the top of the file" << '\n';
176043 }
176044
176045 if (!options.ignore_errors.GetValue()) {
176046 error << "* Enable ignore errors (ignore_errors=true) to ignore potential errors" << '\n';
176047 }
176048
176049 if (!options.null_padding) {
176050 error << "* Enable null padding (null_padding=true) to pad missing columns with NULL values" << '\n';
176051 }
176052 error << "* Check you are using the correct file compression, otherwise set it (e.g., compression = \'zstd\')"
176053 << '\n';
176054 error << "* Be sure that the maximum line size is set to an appropriate value, otherwise set it (e.g., "
176055 "max_line_size=10000000)"
176056 << "\n";
176057 return CSVError(error.str(),
SNIFFING, {});
176058}
@ SNIFFING
If a quote is not terminated.
Definition duckdb.cpp:166190