Danfo.js : 使用 readCSV() / read_csv() 读取 .tsv 文件?
Danfo.js : read .tsv files with readCSV() / read_csv()?
在使用Danfo.js的node.js环境中,使用readCSV()读取.csv文件非常容易,以前是read_csv(),如the official example:
const dfd = require("danfojs-node")
dfd.readCSV("file:///home/Desktop/user_names.csv")
.then(df => {
df.head().print()
}).catch(err=>{
console.log(err);
})
但是,我找不到读取 .tsv
个文件的方法。
有没有办法用 Danfo.js 读取制表符分隔的文件?
在 source 中,我找到了以下评论:
* @param {config} (Optional). A CSV Config object that contains configurations
* for reading and decoding from CSV file(s).
但我是 javascript 的新手,来自 R/Python,不知道该怎么做。
由于它只是一个围绕 tfjs 实现的包装器,读取 tsv 文件尚未在 tfjs 中实现,也许你可以考虑
- 用列替换选项卡并且
- 使用 csv reader
这里是如何使用 readCSV(以前的read_csv)一个 tsv:
dfd.readCSV("file.csv", configs={delimiter:'\t'} )
Parameters: configs: object, optional
Supported params are: ... csvConfigs: other supported Tensorflow csvConfig parameters. See https://js.tensorflow.org/api/latest/#data.csv
然后 that page 说:
csvConfig object optional: ... delimiter (string) The string used to parse each line of the input file.
这意味着您在 tf.data.csv()
中的 csvConfig
中包含的参数也可以包含在 readCSV()
中的 configs
中,例如,如果这样的话:
tf.data.csv(x,csvConfig={y:z})
那么这也行得通:
dfd.readCSV(x,configs={y:z})
PS:有没有其他人注意到 Danfo.js readCSV 出奇地慢? dfd.readCSV 一个 23MB 的 tsv 需要我 9 秒。 dfd.read_json 将其降低到仍然慢得无法使用的 7 秒。将此与使用 apache-arrow js 读取相同数据的 22MB apache arrow 文件所需的 0.015 秒进行比较。
在使用Danfo.js的node.js环境中,使用readCSV()读取.csv文件非常容易,以前是read_csv(),如the official example:
const dfd = require("danfojs-node")
dfd.readCSV("file:///home/Desktop/user_names.csv")
.then(df => {
df.head().print()
}).catch(err=>{
console.log(err);
})
但是,我找不到读取 .tsv
个文件的方法。
有没有办法用 Danfo.js 读取制表符分隔的文件?
在 source 中,我找到了以下评论:
* @param {config} (Optional). A CSV Config object that contains configurations
* for reading and decoding from CSV file(s).
但我是 javascript 的新手,来自 R/Python,不知道该怎么做。
由于它只是一个围绕 tfjs 实现的包装器,读取 tsv 文件尚未在 tfjs 中实现,也许你可以考虑
- 用列替换选项卡并且
- 使用 csv reader
这里是如何使用 readCSV(以前的read_csv)一个 tsv:
dfd.readCSV("file.csv", configs={delimiter:'\t'} )
Parameters: configs: object, optional Supported params are: ... csvConfigs: other supported Tensorflow csvConfig parameters. See https://js.tensorflow.org/api/latest/#data.csv
然后 that page 说:
csvConfig object optional: ... delimiter (string) The string used to parse each line of the input file.
这意味着您在 tf.data.csv()
中的 csvConfig
中包含的参数也可以包含在 readCSV()
中的 configs
中,例如,如果这样的话:
tf.data.csv(x,csvConfig={y:z})
那么这也行得通:
dfd.readCSV(x,configs={y:z})
PS:有没有其他人注意到 Danfo.js readCSV 出奇地慢? dfd.readCSV 一个 23MB 的 tsv 需要我 9 秒。 dfd.read_json 将其降低到仍然慢得无法使用的 7 秒。将此与使用 apache-arrow js 读取相同数据的 22MB apache arrow 文件所需的 0.015 秒进行比较。