LyteNyte Grid logo for light mode. Links back to the documentation home page.
Export & Clipboard

Export Parquet

Export grid data to Apache Parquet using LyteNyte Grid's export API.

This guide uses the Hyparquet Writer library to create Parquet files in the browser. Install this package to enable exporting data to Parquet files.

npm install hyparquet-writer

Parquet Download

The demo below exports grid data to a Parquet file. Parquet is a binary format, so use a Parquet viewer to inspect the output.

Parquet Export & Download

Fork code on stack blitzFork code on code sandbox

To match Parquet’s columnar format, the code below constructs an object of arrays, with one array per column. It passes the object to parquetWriteBuffer, which returns an ArrayBuffer. Finally, it wraps the buffer in a Blob and downloads the file.

<button
data-ln-button="tertiary"
data-ln-size="md"
onClick={async () => {
const api = apiRef.current;
if (!api) return;
const rect = await api.exportData();
const columns = Object.fromEntries(
rect.columns.map((x) => [
x.id,
{
name: x.id,
data: [] as any[],
} satisfies ColumnSource,
]),
);
for (let i = 0; i < rect.data.length; i++) {
const data = rect.data[i];
for (let j = 0; j < rect.columns.length; j++) {
const column = rect.columns[j];
columns[column.id].data.push(data[j]);
}
}
const parquetBuffer = parquetWriteBuffer({
columnData: Object.values(columns),
});
downloadBlob(new Blob([parquetBuffer], { type: "application/octet-stream" }), "data.parquet");
}}
>
Download Parquet File
</button>

Next Steps