having some problems reading a csv file
Posted: Sun Sep 14, 2008 3:55 pm
Hi guys,
Im trying to read in a csv file, parse it and put all the data in the mysql db. I've tried reading/opening the csv file many ways (fopen, fgetcsv, file) and I always the same result.
Every time, every single word, number or phrase gets divided by each character and a diamond with a question mark is inserted in between character. That is how it is saved in the db, and thats how its displayed on the browser. But when you read the actual csv file, everything looks normal.
This simple debug test below shows on the browser just fine the entire line.
A simple explode(",", $line) turns every item extracted like I described above.
Im not sure exactly what the issue is or how to fix. Has this happened to some one?
Many thanks!
Im trying to read in a csv file, parse it and put all the data in the mysql db. I've tried reading/opening the csv file many ways (fopen, fgetcsv, file) and I always the same result.
Every time, every single word, number or phrase gets divided by each character and a diamond with a question mark is inserted in between character. That is how it is saved in the db, and thats how its displayed on the browser. But when you read the actual csv file, everything looks normal.
This simple debug test below shows on the browser just fine the entire line.
Code: Select all
function opencsv($file)
{
$lines = file($file);
foreach ($lines as $pos => $line)
{
echo $line;
}
}Im not sure exactly what the issue is or how to fix. Has this happened to some one?
Many thanks!