hyparquet/README.md

65 lines
2.1 KiB
Markdown
Raw Normal View History

2023-12-29 17:37:37 +00:00
# hyparquet
2023-12-29 18:46:40 +00:00
2023-12-29 20:12:30 +00:00
![hyparquet](hyparquet.jpg)
2024-01-04 19:24:35 +00:00
[![npm](https://img.shields.io/npm/v/hyparquet)](https://www.npmjs.com/package/hyparquet)
2024-01-11 18:46:23 +00:00
[![workflow status](https://github.com/hyparam/hyparquet/actions/workflows/ci.yml/badge.svg)](https://github.com/hyparam/hyparquet/actions)
[![mit license](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![dependencies](https://img.shields.io/badge/Dependencies-0-blueviolet)
2023-12-29 18:46:40 +00:00
2023-12-29 19:27:16 +00:00
JavaScript parser for [Apache Parquet](https://parquet.apache.org) files.
Apache Parquet is an open source, column-oriented data file format designed for efficient data storage and retrieval.
2024-01-03 01:16:33 +00:00
2024-01-03 17:56:17 +00:00
Dependency free since 2023!
2024-01-09 23:15:08 +00:00
## Features
- Designed to work with huge ML datasets (things like [starcoder](https://huggingface.co/datasets/bigcode/starcoderdata))
- Loads metadata separately from data
- Data can be filtered by row and column ranges
- Only fetches the data needed
- Fast data loading for large scale ML applications
- Bring data visualization closer to the user, in the browser
## Installation
2024-01-04 19:24:35 +00:00
```bash
npm install hyparquet
```
2024-01-09 23:15:08 +00:00
## Usage
If you're in a node.js environment, you can load a parquet file with the following example:
```js
const { parquetMetadata } = await import('hyparquet')
const fs = await import('fs')
const buffer = fs.readFileSync('example.parquet')
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)
const metadata = parquetMetadata(arrayBuffer)
```
If you're in a browser environment, you'll probably get parquet file data from either a drag-and-dropped file from the user, or downloaded from the web.
To load parquet data in the browser from a remote server using `fetch`:
2024-01-04 19:24:35 +00:00
```js
import { parquetMetadata } from 'hyparquet'
2024-01-09 23:15:08 +00:00
const res = await fetch(url)
const arrayBuffer = await res.arrayBuffer()
const metadata = parquetMetadata(arrayBuffer)
2024-01-04 19:24:35 +00:00
```
2024-01-09 23:15:08 +00:00
To parse parquet files from a user drag-and-drop action, see example in [index.html](index.html).
2024-01-03 01:16:33 +00:00
## References
- https://github.com/apache/parquet-format
- https://github.com/dask/fastparquet
- https://github.com/apache/thrift
- https://github.com/google/snappy
- https://github.com/zhipeng-jia/snappyjs