MySQL, loading fixed width file

LOAD DATA INFILE '/tmp/test.txt'
INTO TABLE table(@var) SET
name=Trim(SUBSTR(@var,1,24)),
something=Trim(SUBSTR(@var,25,4)),
else=Trim(SUBSTR(@var,29,3));

The first number is the starting row, the second number is the length of the field. @var in this example is a randomly named variable. Name, something & else describe the databaseĀ column(s).

Back to Top