javascript - javascript 无法写入镶木地板文件(始终为 1kb)
问题描述
我想弄清楚如何使用nodejs创建数据并将其写入镶木地板文件。我在下面创建了非常简单的代码:
var parquet = require('parquetjs');
init();
async function init(){
console.log('BEGIN DEBUG PARQUET')
var debugschema = new parquet.ParquetSchema({
name: { type: 'UTF8' },
quantity: { type: 'INT64' },
price: { type: 'DOUBLE' },
date: { type: 'TIMESTAMP_MILLIS' },
in_stock: { type: 'BOOLEAN' }
});
// create new ParquetWriter that writes to 'fruits.parquet`
var debugwriter = await parquet.ParquetWriter.openFile(debugschema, `./DEBUGPARQUET.parquet`);
// append a few rows to the file
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
console.log('END DEBUG PARQUET')
}
我node index.js
在 Windows 10 命令提示符终端中使用命令运行,文件运行没有错误,现在我有一个DEBUGPARQUET.parquet
只有 1 kb 大小的文件,我根本无法打开这个文件来查看镶木地板数据(我尝试安装 apache parquet view 程序并使用它,但它不起作用,我无法在带有 parquet 扩展名的 vscode 中查看文件的内容,并且查看 parquet 文件的在线站点也不起作用)
我的代码中是否缺少某些内容?还是在 Windows 10 上编写镶木地板文件有问题?
解决方案
var debugwriter = await parquet.ParquetWriter.openFile(debugschema, `./DEBUGPARQUET.parquet`);
// append a few rows to the file
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.appendRow({name: 'apples', quantity: 10, price: 2.5, date: new Date(), in_stock: true});
await debugwriter.close();
console.log('END DEBUG PARQUET')
推荐阅读
- javascript - Outlook 加载项 | Office.context.mailbox.item.body.getAsync() 问题
- c# - 有没有办法在 Unity 2D Light System 中隐藏处于阴影中的玩家?
- html - Flexbox 定位和背景
- c++ - 如何使用 `requires` 和 `-> return_type` 声明成员函数
- ruby-on-rails - 如何修复以前重命名和覆盖现有迁移
- c# - SSRS 表达式问题。无法在表达式中使用嵌套聚合
- javascript - 如何链接返回 Promise 的 API 请求,该请求在数组中有一个字段?
- python - 从 GCS 存储桶中的文件夹中删除数百万个对象
- php - 在 localhost php 页面上执行 laravel 项目后显示错误 url not found
- php - 如何在 mysql 中保存月份名称(例如:2020 年 1 月而不是 2020-01)?