I have code that pulls data from infusionsoft api and writes it to a csv file. the issue is the data isn't all that clean in the database and some strings have double quotes surrounding the data. Other strings have a line feed character in the data. When it writes out to the csv and i try to bring it into excel these characters effect the data. See code below. what i want to do is after the data is read into the array, step through the array and remove the quotes and line feeds before it moves to the csv. Can someone help me with this? My code is below
We do not need all of it - just enough to see the data elements that are troublesome.
Also, is this UTF-8? If it is, you might need a byte-order mark for Excel.
mitai
ASKER
there are multiple tables that I use this for here is one sample
is there a way to check each element in the $results (or result) and see if the object is a string, then do the remove quotes and linefeeds. I can run a sample on my contact but it will take a while as there are 400+ thousand of them
Hmm... Has this application ever been used to produce a CSV file? And what is the return value from $result->toArray() method? I am guessing that it would be the array inside the data property, which is protected, so we cannot access it directly. Would be good to confirm that.
mitai
ASKER
Here is the results from one of the impacted records in the contact file. you will notice that the one field () has Initials=AA then has a line feed character. This is causing excel to drop the remaining part of this record to the next line. note I have sanitized the data here so if something doesn't look right with a string it has been replaced with XXXXX