'How can I read .dat file in node.js and convert to human-readable text/json

I have a .dat file that contains information that is not clear to read it.

So, I was trying to read that file and convert it to human-readable text/json.

I implemented this code but don't know how to convert readable text/json file.

 fs.readFile('./2.dat', 'utf8', (err, data) => {
    if (err) throw err
    console.log(data)
  })

This is the file 2.dat



Solution 1:[1]

Your file looks like some kinf of CSV with | as a delimiter. YOu need to use some package to parse CSV like csv-parse to get lines as JS-objects.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anatoly