Hemant
Hemant

Reputation: 11

How to read csv with fs readfile when line separator is new line char and csv data has new line characters in it?

I am reading the csv using CSVData = fs.readFile(File.csv, "utf-8").

Using new line character as separator CSVData.split(/\r\n|\n/) to read each line.

But there are some rows having data with newline char.

for e.g. in below table row3-colB has data with \n

sample data

How I can read such rows using fs? Now our code has many lines and replacing fs with any other liabrary will be a big task. If anyone can suggest alternate solution.

Upvotes: 0

Views: 680

Answers (1)

Hemant
Hemant

Reputation: 11

I found the solution that I can replace \n in double quotes. Thanks for the hint @Mitch Lillie

Find & replace line breaks between double quotes

Upvotes: 1

Related Questions