web-csv-toolbox - v0.14.0
    Preparing search index...

    Function parseBlob

    • Parse CSV from a Blob or File to records.

      Type Parameters

      Parameters

      • blob: Blob

        The blob or file to parse

      • Optionaloptions: Options

        Parsing options

      Returns AsyncIterableIterator<InferCSVRecord<Header, Options>>

      Async iterable iterator of records.

      If you want array of records, use parseBlob.toArray function.

      This function can parse CSV data from Blob or File objects. If the Blob has a type with charset parameter, it will be used for decoding.

      File objects (from file inputs or drag-and-drop) extend Blob and are automatically supported.

      import { parseBlob } from 'web-csv-toolbox';

      const blob = new Blob(['name,age\nAlice,42\nBob,69'], { type: 'text/csv' });

      for await (const record of parseBlob(blob)) {
      console.log(record);
      }
      import { parseBlob } from 'web-csv-toolbox';

      const input = document.querySelector('input[type="file"]');
      input.addEventListener('change', async (event) => {
      const file = event.target.files[0];
      for await (const record of parseBlob(file)) {
      console.log(record);
      }
      });
      import { parseBlob } from 'web-csv-toolbox';

      const blob = new Blob([csvData], { type: 'text/csv;charset=shift-jis' });

      for await (const record of parseBlob(blob)) {
      console.log(record);
      }