Reading problems with CSV and PHP [closed]

1

I tell you my problem:

I download from Facebook a list of potential customers obtained to hear canoalas advertising. That file is in CSV UTF-16 format.

What I do first of all to modify the encoding and pass it to UTF-8 is:

iconv -f UTF-16 -t UTF-8 ingreso.csv > datos-facebook.csv;
chmod 777 datos-facebook.csv;

In this way I modify the encoding and I generate a new file with the encoding of UTF-8.

Then, by means of $file = fopen('datos-facebook.csv', 'r'); I open the file, check that it is not empty and then I go through it using while (($line = fgetcsv($file)) !== FALSE) and store the results of while in variables that I then insert in the db.

The problem I'm having is that yes or yes I have to enter the CSV file (with Open Office) and press save and exit and that's where the code works perfectly. On the other hand, if I do not do that extra step, it does not read the file.

I began to compare the original file and the one I opened and pressed save and the difference I noticed is that it takes out the quotes ( " " ) of each text. Does anyone have an idea how to do this? Because I can not read any data unless I take that extra step.

    
asked by JuanManuel245 14.08.2018 в 17:59
source

0 answers