Hi Philip,

The way I did this was through the table...

export function encodeTable(table:Table):DataBlock {
  let schema, records;
  let w = new RecordBatchStreamWriter();
  w.reset(undefined, table.schema);
  schema = Buffer.from(w.toUint8Array(true)).toString('base64');
  w = new RecordBatchStreamWriter();
  w.write(table);
  records =
Buffer.from(w.toUint8Array(true)).toString('base64').replace(schema,'');
  return {
    aId: uuidv4(),
    schema,
    records
  };
}

Note, the DataBlock being returned here and separation of the records and
the schema was specific to my application which was working with AWS
Athena.  You may not need this for your own.  Also, if you're looking at
writing to a file, take a look at replacing my use of
RecordBatchStreamWriter with RecordBatchFileWriter.

As far as creating the Table goes, there are a few different arrow helper
functions for that.

-H



On Wed, Jun 8, 2022 at 12:30 PM Philip Zeyliger <
[email protected]> wrote:

> Hi!
>
> I'm trying to write an Arrow file from JS, and having trouble finding
> examples of writing (not reading) in the documentation/cookbooks. Pointers
> to examples would be appreciated!
>
> Thanks!
>
> -- Philip
>

Reply via email to