Search code examples
mysqlload-data-infiledelimiternon-printable

Using MySQL LOAD DATA INFILE with nonprintable character delimiters


I have some vendor data that has the SOH (ASCII character 1) as the field delimiter and STX (ASCII character 2) as the record delimiter. Is it possible to load this data with LOAD DATA INFILE without pre-processing the file and replacing those characters with something more common?


Solution

  • I got it.

    LOAD DATA LOCAL INFILE 'myfile.txt' INTO TABLE my_table 
        CHARACTER SET UTF8 
        FIELDS TERMINATED BY X'01'
        LINES TERMINATED BY X'02'
        (col1, col2, col3);