Title: LOAD Post by: Jose Edvandro M. on October 17, 2023, 01:55:46 pm I have a csv file, I'm trying to import it with the LOAD command. However, this file has a header. How do I import the file without importing the first line, which is the header?
Title: Re: LOAD Post by: Reuben B. on October 19, 2023, 12:38:37 am With the LOAD we match the Informix-4gl LOAD statement which I don't believe has the ability to skip first row. Having said I don't see what stops us adding syntax to ...
Code
... and adding a keyword similar to ... Code
as that would not break compatibility. However that does not help you now. Your current options might include ... using tail to remove the first line, something like Code
or also suggested here https://stackoverflow.com/questions/28478657/informix-load-from-file-with-header load into a temp table which is all chars and then delete or ignore the first row before loading to destination table. or you can explore writing your own generic library function using base.Channel, base.SqlHandle, base.StringTokenizer Something like this as a starting point, need to add error handling, cater for case where delimiter is at end etc. Code
(it would be nice if there was a method that combined ch.read and hdl.setParameter to avoid use of tokenizer (tokenizer doesn't have CSV as a delimiter ...) Hope that helps, Reuben Title: Re: LOAD Post by: Michelle B. on January 15, 2024, 10:41:38 am I have a csv file, I'm trying to import it with the LOAD command. However, this file has asmash karts (https://smashkartsio.com)header. How do I import the file without importing the first line, which is the header? If you are trying to import a CSV file with a header using the LOAD command, you can use the IGNORE keyword to skip the first line of the file. Here’s an example:LOAD DATA INFILE 'filename.csv' INTO TABLE tablename FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 ROWS; The IGNORE 1 ROWS statement tells MySQL to skip the first row of the file, which is the header. This will allow you to import the data from the CSV file without including the header row. Title: Re: LOAD Post by: Clifton E. on February 15, 2024, 09:39:35 am If you are trying to import a CSV file with a header using the LOAD command, you can use the IGNORE keyword to skip the first line of the file. Here’s an example: Many thanks for that solution. basket random (https://basketrandom.io) LOAD DATA INFILE 'filename.csv' INTO TABLE tablename FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 ROWS; The IGNORE 1 ROWS statement tells MySQL to skip the first row of the file, which is the header. This will allow you to import the data from the CSV file without including the header row. Regard, Clifton Evans Title: Re: LOAD Post by: Jose Edvandro M. on February 21, 2024, 05:04:14 pm I have a csv file, I'm trying to import it with the LOAD command. However, this file has asmash karts (https://smashkartsio.com)header. How do I import the file without importing the first line, which is the header? If you are trying to import a CSV file with a header using the LOAD command, you can use the IGNORE keyword to skip the first line of the file. Here’s an example:LOAD DATA INFILE 'filename.csv' INTO TABLE tablename FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 ROWS; The IGNORE 1 ROWS statement tells MySQL to skip the first row of the file, which is the header. This will allow you to import the data from the CSV file without including the header row. LOAD DATA INFILE works only for mysql. We work with postgresql, sql server, informix and oracle |