I am using the fgetcsv () function in PHP to read a CSV file that is created using Microsoft Excel.
The problem is that the CSV file contains a comma value and it reads the escaped value (with double quotes) as it is.
For example: "2,5,7" reads as "2 and 5 and 8"
The problem can be resolved by changing double quotes to single quotation mark. However, I do not want to edit every CSV file every time.
The code I use is as follows:
$ handle = fopen ($ path, "r");
$ data = fgetcsv ($ handle, 1000, ",", "'");
do
{
** READ CSV **
}
while ($ data = fgetcsv ($ handle, 5000, ","));
What would be the best way to deal with this problem?
source share