Hello,
I am currently facing some trouble with .csv import using a form. I am trying to use a code after uploading .csv, but it looks like OPTIONALLY ENCLOSED BY ‘"’ does not work proper since I am missing 1st value of each line…import just skips the first value of each line. Since I am only allowed to use OPTIONALLY ENCLOSED BY ‘"’ with SC, i will need a solution that will work with any .csv that has the following format:
CSV:
“line1-value1”,“line1-value2”
“line2-value1”,“line2-value2”
Code:
$sql = "LOAD DATA LOCAL INFILE '$my_csv'
INTO TABLE `data_csv`
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY ''
(`value1`,
`value2`)";
sc_exec_sql($sql);
Another question: Is it possible to check if there are any duplicates being imported during import (in case one dataset has already been imported) and skip those lines. I would like to count those duplicates during import as well and fetch the number of duplicates into a variable.