I have ASCII files with a static number of characters for each line with no delimiters. I\'d like to use LOAD DATA INFILE to import into my table.
Example of file:
Another way to do this is just assigning a variable and splitting it direct in your load.
LOAD DATA INFILE 'yourfilegoeshere' INTO TABLE main_table
LINES TERMINATED BY '\r\n' (@_var)
set
field1=TRIM(SUBSTR(@_var from 1 for 2)),
field2=TRIM(SUBSTR(@_var from 3 for 2)),
field3=TRIM(SUBSTR(@_var from 5 for 70));
Just be sure not to specify any field separator, otherwise you will have to use more variables, note that I'm using TRIM to clean data in the same statement.