Currently, I have product descriptions stored in an object as strings. My goal is to transfer this data to a CSV file for further data analysis.
The challenge lies in making the data visually appealing for easy readability. Thus far, all I've managed to achieve is a collection of tightly packed, hard-to-read strings.
When editing in Excel, using Alt+Enter creates spacing within the same row. How can I write the data to the file with line spaces that don't result in new rows in Excel?
Through my research, I discovered:
\n
gets copied as text\r\n
starts a new row instead of simply adding space within the row
For instance:
fs.appendFile(`./data/testCSV.csv`, encodeURIComponent(element.name +'\r\n'+ element.description + '\r\n'+ element.short_description), function (err) {
if (err) throw err;
});
This code snippet results in three separate rows of data.
Here's an example of the desired formatting:
https://i.sstatic.net/AVePI.png
I also attempted to find an NPM parser that could solve this issue, but it seems all options create new lines as well.