distal-attribute
distal-attribute
distal-attribute
distal-attribute

Ignore empty lines in CSV import?

User, date Message
Written by JanSR
7 years ago
Category: Import/Export
5 posts since Thu, 26 Oct 06
I have an excel-sheet, which I need to save as CSV and then import in to mySQL via Heidi. Sadly the Excel-Sheet seems to contain loads more "Returns" than it has lines, all of these get imported into mySQL obviously.

Would it be possible to add an option in the "import csv"-Settings to say "ignore empty lines"? This would - if checked - just import lines that actually contain more than just field-terminators and line breaks.

? Jan
Written by ansgar
7 years ago
4955 posts since Fri, 07 Apr 06
Unfortunately the LOAD DATA-syntax does not allow ignoring specific lines. Only a fixed number of top-lines can be ignored by "IGNORE X LINES".

See here: http://dev.mysql.com/doc/refman/5.0/en/load-data.html

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[CHARACTER SET charset_name]
[FIELDS
[TERMINATED BY 'string']
[[OPTIONALLY] ENCLOSED BY 'char']
[ESCAPED BY 'char']
]
[LINES
[STARTING BY 'string']
[TERMINATED BY 'string']
]
[IGNORE number LINES]
[(col_name_or_user_var,...)]
[SET col_name = expr,...]



That means we would have to first manipulate the file, maybe save a temporarily copy of it and then fire the LOAD-command.

Could be good. We should submit a tracker-item at http://rfe.heidisql.com/
Written by siMKin
7 years ago
104 posts since Sun, 01 Apr 07
while you're at it, maybe you could also consider adding a replace functionality through regular expressions :)
i have never had the need for it, but i can imagine it might be useful for some.
 

Please login to leave a reply, or register at first.