I have a csv file comma delimited. Some of the data is double quote encaps where address field has comma caused by user input from web form.
Ie. 12345,"235 main street, apt3",boston,ma,12431
When i try to use putcsv function and import into sql the extra comma that is encaps is causing apt3 to write into the city column and city into the state column, etc.
How can i clean this up before importing?
I tried this but dont work.
$file_path = "/my/path";
$file = $file_path . "filename.csv";
$handle = fopen("$file", "r");
$array = explode("\n", fread($handle, filesize("$file")));
$total_array = count($array);
$i = 0;
$handle2 = fopen('filename2.csv', 'w');
while($i < $total_array)
$data = explode(",", $array[$i]);
fputcsv($handle2, $data, $sSeparator='|', $sEnclosure='"');