0

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.

Hemant
  • 11
  • 3
  • 1
    Per the CSV spec, fields containing newlines should be enclosed in double quotes. For example, the following is just two CSV rows: 'one,two,three\naaa,"b\nbb",ccc' Is this what your data looks like? Can you include the raw data? – Mitch Lillie Jun 26 '19 at 18:04
  • That is right here is the raw data: 'G88,G8888\n G99, "G9999\nG99991111",G101010,G101010' – Hemant Jun 27 '19 at 04:23

1 Answers1

1

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

Hemant
  • 11
  • 3