I'm trying to import multiple tsv files in a mysql database. Problem is that there are 8 columns but there a some empty fields.
The tsv looks like:
Test1 3 -2 YEHD 4473 TR 94059 02948
Test2 5 -7 4029 HDU 37465 02948
Test2 5 -7 HDYEG 2039 UEJ 93844
Test2 7 0 HDUI JWI 02948
Test3 7 1 YEHV 2843 JHW 88283
I've tried to import one of the files with LOAD DATA LOCAL INFILE but the import skips the empty fields:
LOAD DATA LOCAL INFILE 'filename.csv' INTO TABLE my_table
FIELDS TERMINATED BY '\t'
ENCLOSED BY ''
LINES TERMINATED BY '\n'
How can I import files like this in MySQL with an output like this:
| column1 | column2 | column3 | column4 | column5 | column7 | column8 | column8 |
---------------------------------------------------------------------------------
| Test1 | 3 | -2 | YEHD | 4473 | TR | 94059 | 02948 |
| Test2 | 5 | -7 | | 4029 | HDU | 37465 | 02948 |
| Test3 | 5 | -7 | HDYEG | 2039 | UEJ | | 93844 |
Edit When I change the tab separation to a comma separation it works (MySQL load NULL values from CSV data). But is it possible to do this with a tab separated file? Or is is just easier to convert all the files from a tab to a comma (how can i do this automated)?