If you have a (foreign key) constraint defined in your target table such that records with a blank value in the type
column will be rejected, you could use MySQL's LOAD DATA INFILE
to read the first column into a user variable (which is carried forward into subsequent records) and apply its IGNORE
keyword to skip those "records" that fail the FK constraint:
LOAD DATA INFILE '/path/to/file.csv'
IGNORE
INTO TABLE my_table
CHARACTER SET utf8
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 4 LINES
(@a, type, date, terms, due_date, class, aging, balance)
SET account_no = @account_no := IF(@a='', @account_no, @a)