Can someone help me with code to remove carriage returns from submissions?
I need to remove them because the CSVs are coming through with line breaks and Excel is reading the breaks and putting data into the wrong columns. I found this code online, but I’m getting a PHP error on the closing bracket when saving (I’m not a developer) - I need the code to apply to all forms:
/* Strip carriage returns in Gravity Form submissions*/
_POST[“input_11”] = preg_replace("/\r?\n/", " ", ($_POST[“input_11”]))
/* End Gravity Forms strip carriage returns*/
Thanks in advance for any help!
Hi Stacey. You can normally configure Excel to ignore those carriage returns, and ensure all the text from a textarea stays in one column in the spreadsheet. Also, have you tried using Google Sheets to open the CSV? I’ve found in the past that it is much smarter about opening Gravity Forms CSV entry exports, and keeping all the data in the correct columns.
That is not a solution to what you were initially asking, but maybe there is another way to open your export without having to modify the data before the entry is created.
I had not thought of trying Google Sheets. I tried Numbers and Excel, with poor results - but Google Sheets figured it out. Thanks much for the suggestion!
That’s awesome. I’m glad that worked for you. I’ll close this topic but if you need any other assistance, feel free to open a new one or open a support ticket. Thank you.