I have a csv file that I need to import to a remote Mysql DB. The structure of the csv is as follow:
sep=,
"Affiliate ID","Affiliate Name","Affiliate First Name","Affiliate Surname","Affiliate Status","Affiliate E-mail","Marketing Source","Parent Affiliate ID","Parent Affiliate Name","Affiliate Groups","Signup Date","Affiliate Review Type","Country","Affiliate Type","Whois","Signup Comment",
"654673","Traffic A","A","B","Approved","a@ts","T","N/A","N/A","N/A","21/09/2022 14:22:00","Generic","UK","Generic","[WhoIS]","N/A",
"654672","TL","Joe","BI","Approved","[email protected]","zoo","N/A","N/A","N/A","21/09/2022 08:23:00","Generic","India","Generic","[WhoIS]","N/A",
"654671","BJoe","J ","Doed","Approved","[email protected]","you","N/A","N/A","N/A","21/09/2022 07:53:00","Generic","greece","Generic","[WhoIS]","N/A",
"654670","Collectc","ba","mo","Approved","[email protected]","youtube","N/A","N/A","N/A","21/09/2022 06:44:00","Generic","irland","Generic","[WhoIS]","N/A",
Before anything, I am deleting the first line including sep=, using the following script:
set "csv=C:\Users\SERVER\Downloads\Affiliates.csv"
more +1 "%csv%" >"%csv%.new"
move /y "%csv%.new" "%csv%" >nul
I then try to import the file using the mysqlimport function:
"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqlimport.exe" -h server.com -P 3306 -u user -pPassword --local --ignore-lines=1 --fields-terminated-by=, --fields-optionally-enclosed-by='\"' --lines-terminated-by="\r\n" database C:\Users\SERVER\Downloads\Affiliates.csv
but it seems that my instruction --fields-optionally-enclosed-by='\"' fails
If i omit this instruction, the the file is properly imported to DB including the double quotes...
I do not know if there is a way to fix the mysqlimport instruction or if i need to remove all double quote in the csv file to allow an easier import...
Change the order of
--fields-optionally-enclosed-by='"'and I don't think you really need to pass\.