BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/retab-ui/csv

CSV parser

retab-ui/csv
FreeUtility

A small, dependency-free RFC 4180-ish CSV/TSV parser returning a header and rectangular rows.

Install it

npx shadcn@latest add https://ui.retab.com/r/csv.json

Source

registry/new-york-v4/lib/csv.tsui.retab.com/r/csv.json
1import {
2 createCsvNormalizer,
3 padRowsToColumnCount,
4 type CsvNormalizer,
5} from "./csv-normalizer";
6import { createCsvParser } from "./csv-parser";
7
8export {
9 DEFAULT_CSV_DIALECT,
10 extensionOfDelimitedName,
11 inferCsvDialect,
12 isTabDelimited,
13 normalizeCsvDelimiter,
14 resolveCsvDialect,
15 type CsvDialect,
16 type CsvDialectDescriptor,
17} from "./csv-dialect";
18export {
19 createCsvNormalizer,
20 padRowsToColumnCount,
21 type CsvNormalizer,
22 type CsvNormalizerOptions,
23 type CsvTable,
24 type CsvTableEvent,
25} from "./csv-normalizer";
26export {
27 createCsvParser,
28 type CsvParser,
29 type CsvParserOptions,
30} from "./csv-parser";
31
32export interface ParsedCsv {
33 columns: string[];
34 rows: string[][];
35}
36
37export interface ParseCsvOptions {
38 /** Field delimiter. Defaults to ",". */
39 delimiter?: string;
40 /** Treat the first record as a header row. Defaults to true. */
41 hasHeader?: boolean;
42}
43
44export function parseCsv(
45 input: string,
46 options: ParseCsvOptions = {},
47): ParsedCsv {
48 const parser = createCsvParser({ delimiter: options.delimiter });
49 const normalizer = createCsvNormalizer({ hasHeader: options.hasHeader });
50 const rows: string[][] = [];
51 let columns: string[] = [];
52
53 handleCsvRecords(parser.push(input), normalizer, rows, (nextColumns) => {
54 columns = nextColumns;
55 padRowsToColumnCount(rows, columns.length);
56 });
57 handleCsvRecords(parser.flush(), normalizer, rows, (nextColumns) => {
58 columns = nextColumns;
59 padRowsToColumnCount(rows, columns.length);
60 });
61
62 return { columns, rows };
63}
64
65function handleCsvRecords(
66 records: string[][],
67 normalizer: CsvNormalizer,
68 rows: string[][],
69 onColumns: (columns: string[]) => void,
70) {
71 for (const record of records) {
72 for (const event of normalizer.accept(record)) {
73 if (event.type === "columns") {
74 onColumns(event.columns);
75 } else {
76 rows.push(event.row);
77 }
78 }
79 }
80}
81
82/** Pad a record to a fixed width. */
83export function fitRow(row: string[], width: number): string[] {
84 if (row.length === width) return row;
85 if (row.length < width)
86 return [...row, ...Array(width - row.length).fill("")];
87 return row;
88}
89
90export interface CsvStreamHandlers {
91 onColumns: (columns: string[]) => void;
92 onRows: (rows: string[][]) => void;
93 onDone?: () => void;
94 onError?: (error: unknown) => void;
95}
96
97export interface CsvStreamOptions extends ParseCsvOptions {
98 /** Rows per batch handed to `onRows`. Defaults to 2000. */
99 batchSize?: number;
100// … truncated

Files it writes

  • registry/new-york-v4/lib/csv.ts
  • registry/new-york-v4/lib/csv-parser.ts
  • registry/new-york-v4/lib/csv-normalizer.ts
  • registry/new-york-v4/lib/csv-dialect.ts

Facts

Registry
retab-ui
Type
registry:lib
Access
Free
Files written
4
Licence
NOASSERTION
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

ui.retab.com retab-dev/retab-ui on GitHub Raw registry item This item as JSON

More from retab-ui

All 130 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Document source modeldocument-sourceretab-uiUtilitiesFreeno deps
DOCX Document Resourcedocx-document-resourceretab-uiUtilitiesFreeno deps · 5 files
Effect Keyeffect-keyretab-uiUtilitiesFreeno deps
PDF Document Resourcepdf-document-resourceretab-uiUtilitiesFree1 dep · 6 files
Segment Interactionsegment-interactionretab-uiUtilitiesFreeno deps
Segments modelsegmentsretab-uiUtilitiesFreeno deps
Utilsutilsretab-uiUtilitiesFree2 deps
XLSX SheetJS flattenerxlsx-sheetjs-flattenerretab-uiUtilitiesFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex