2

所以我得到了一个要导入的 NDJSON 文件,然后在表格中的网页上显示。我在数据中不断收到错误,我对格式感到满意。我将删除有问题的变量,它会继续下一个。

我试过查看 npm ndjson 但我很困惑,因为没有大量关于实现的解释。

观察.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!");
      }
  )
;
}
);
4

0 回答 0