infobright import data encountered a special character error solution

  • 2020-06-23 02:08:22
  • OfStack

Currently, the community version of infobright is used. DML is not supported, and data can only be imported by LOAD DATA.

If there are special control characters in the metadata, errors are often reported during the import process, which is annoying. There are two approaches to coping strategies:

1. Before setting Reject File import, set @BH_ES12en_ES13en_PATH and @BH_ES16en_ES17en_COUNT to ignore the number of failed import records and save them in the specified file

/** when the number of rows rejected reaches 10, abort process **/
set @BH_REJECT_FILE_PATH = '/tmp/reject_file';
set @BH_ABORT_ON_COUNT = 10;
BH_ABORT_ON_COUNT  Set to  -1  Never ignore it. 

You can also set the BH_ABORT_ON_THRESHOLD option, which indicates the maximum percentage of data that can be ignored, so the value of the option is in decimal format, such as BH_ABORT_ON_THRESHOLD = 0.03 (for 3%)

In addition, you can specify an end character when exporting data and set which escape characters (\, ", ', etc.) to be ignored, such as:

select fields_list... into outfile '/tmp/outfile.csv' fields terminated by '||' ESCAPED BY '\\' lines terminated by '\r\n' from mytable;

3. Or, set the line interval to some other special identifier, such as select fields_list... into outfile '/ tmp/outfile csv' fields terminated by '| |' ESCAPED BY '\ \' lines terminated by '$$$$$\ r \ n' from mytable; Of course, in this case, the value "$$$$$$$\r" cannot exist in the actual data row, otherwise it will be treated as a newline identifier.


Related articles: