We have a CSV file, which we have meticulously checked and stripped to show the data in the format we want.
As such this csv file is, just under 500kb in size. I have converted to sql ( saved as txt ) hope thats ok.
The original csv data entry is 3 fields, as thus:
‘STANLEY’,’7331′,’TAS’
‘GORMANSTON’,’7466′,’TAS’
After conversion its like so:
INSERT INTO suburbs ('Locality','Pcode','State') VALUES (‘\’STANLEY\”,’\’7331\”,’\’TAS\”);
INSERT INTO suburbs ('Locality','Pcode','State') VALUES (‘\’GORMANSTON\”,’\’7466\”,’\’TAS\”);
Ok now, not being a db officianado, I would like to know. Have I converted it correctly ?
Should I be looking at making this code cleaner for import to the db.
The sql is over 1.6 mb for this file, with over 16,000 entries, so want to make sure I have done things correctly.
Cheers
As with what Adam’s comment said, you’re most likely not going to want to insert the quotes, which you are doing with \’STANLEY\’ etc.
Also, on the ‘field’ side (locality etc), make sure those are back ticks (non-shift tilde), and the data side (STANLEY) are single quotes.
change to:
Other than that, I don’t see anything wrong with it.