Hi everyone
I have an issue because in some places my product descriptions contain line breaks (not
code), which means that if I export the product data to CSV and open in Excel, it messes things up as it converts the line breaks to new rows.
I’ve done some research and found lots of discussion about liquid code to strip out new lines or replace them with
, I assume when displaying an actual page. But is there a way to actually remove the new lines from the data itself?
Or does anyone know of a better way to export the data where it won’t cause that issue?
Thank you.
Matt
Hey there @Matthew_Harper1 ,
On the data exporting side, if you’re open to using an app, our EZ Exporter app might be able to help with this.
Our app has a feature called “Calculated Fields” where you can enter a formula like this to automatically strip out carriage return and newline characters on export:
{{ body_html }}.replace("\r", "").replace("\n", "")
We have a function that can also automatically remove the HTML tags and combine it with the replace() above to remove both HTML tags and newline characters:
strip_html_tags({{ body_html }}).replace("\r", "").replace("\n", "")
We also support exporting directly to Excel format (we support both xls and xlsx formats).
Feel free to reach out to us if you have any questions on this.