瀏覽代碼

Fix reading datasets

this shall speed up the load by a tiny bit
jmacura 4 年之前
父節點
當前提交
194828f999
共有 1 個文件被更改,包括 2 次插入3 次删除
  1. 2 3
      nuts-data.js

+ 2 - 3
nuts-data.js

@@ -8,16 +8,15 @@ module.exports.loadDatasets = async function(filePath) {
     let datasets = undefined
 
     return new Promise((resolve, reject) => {
-    const stream = fs.createReadStream(filePath).pipe(csv())
+    const stream = fs.createReadStream(filePath).pipe(csv({to_line: 1}))
     stream
         .on('data', (row) => {
             if (!datasets) {
                 datasets = row
             }
-            stream.end()
         })
         .on('end', () => {
-            datasets = datasets.slice(1) //unify this number (only one ID column in the beginning)
+            datasets = datasets.slice(2) //TODO: FIXME: unify this number (only one ID column in the beginning)
             console.log('Datasets structure loaded.')
             resolve(datasets)
         })