2

So I've been given a NDJSON file to import and then display on a webpage in a table. I keep getting an error inside the data and I feel like it with the format. I will delete the variable with the issue and it will go on to the next one.

I've tried looking at npm ndjson but I'm confused because there isn't a ton of explanation on implementation.

Observation.ndjson

{"resourceType": "Observation", "id":"35i123", "status": "final", "category":[{"coding":[.........]}]}
{"resourceType":"Observation"......}

index.js

var transformStream= ndjson.stringify();
var outputStream = transformStream.pipe(fileSystem.createReadStream("./Observation.ndjson"));
outputStream.on(
"finish", function handleFinish(){
console.log("ndjson serialize completed!");
}
);

outputStream.on(
"finish", function handleFinish() {
var inputStream = fileSystem.createReadStream(__dirname + "./Observation.ndjson")
var transformStream=inputStream.pipe(ndjson.parse("./Observation.ndjson"));
transformStream
             .on( "data", function handleRecord(data){
             function handleRecord(data){
              console.log("record(event):", data);
         } 
      }
   )
        .on("end", function handleEnd(){
         console.log("ndjson parsing complete!");
      }
  )
;
}
);
jenna
  • 113
  • 8
  • What error are you getting? And, don't you want to be parsing this stream rather than stringifying it? – Brad Jul 11 '19 at 18:44
  • I'm getting an unexpected token : but its pointing to the middle of the word "display" – jenna Jul 11 '19 at 18:54

0 Answers0