Fixed width file is too large to use Access, so I attempted to write a PHP script to import using LOAD DATA LOCAL INFILE, but it is not working.
Can someone take a look and tell me why? Set up my table structure correctly (originally as part of the PHP script, then manually in phpMyAdmin to ensure it was not an error in this part).
Here is the import query (shortened by about 400 fields for brevity's sake):
$db->query("LOAD DATA LOCAL INFILE 'D:\x\yz' INTO TABLE abc SET
cat_provider=SUBSTR(pos,3,2),
cat_sub_provider=SUBSTR(pos,1,2),
chow_count=SUBSTR(pos,5,2),
chow_date=SUBSTR(pos,7,8),
city=SUBSTR(pos,15,28),
numberwaivedindividuals=SUBSTR(pos,2093,6),
pendinglaboratoryclassification=SUBSTR(pos,2099,2),
previouslyregulatedindicator=SUBSTR(pos,2101,1),
sharedlabcrossreference_num_=SUBSTR(pos,2102,10),
sharedlabindicator=SUBSTR(pos,2112,1),
surveycertificateschedulecode=SUBSTR(pos,2113,1),
surveycomplianceschedulecode=SUBSTR(pos,2114,1),
surveytestvolumetotal=SUBSTR(pos,2115,9),
terminationcode=SUBSTR(pos,2124,2),
totalwaivedtestvol=SUBSTR(pos,2126,9),
ignore 1 lines");
Do I need to put 'fields terminated by '\r\n' ?
Also, I would welcome any references or suggestions on how to otherwise convert this file to CSV or some other format that is easily importable.
Many thanks.