FreeStack

CSV Importer

Smart CSV import UI with column mapping, data validation, preview table, and error highlighting. Handles large files with streaming and shows progress for batch imports.

ReactDataBuilt with Cursor
980
Stars
4.5k
Installs
2
Deps
2
Comments

Install / Copy

npx create-freestack-module csv-importer

Code Preview

index.tsx
import Papa from "papaparse";

export function CSVImporter({ schema, onImport }) {
  const [step, setStep] = useState("upload"); // upload | map | preview | done
  const [data, setData] = useState([]);
  const [mapping, setMapping] = useState({});

  const handleFile = (file: File) => {
    Papa.parse(file, {
      header: true,
      complete: (results) => {
        setData(results.data);
        setMapping(autoMapColumns(results.meta.fields, schema));
        setStep("map");
      },
    });
  };

  const handleImport = async () => {
    const mapped = data.map((row) => applyMapping(row, mapping, schema));
    const { valid, errors } = validate(mapped, schema);
    if (errors.length > 0) return showErrors(errors);
    await onImport(valid);
    setStep("done");
  };
}
DA
dataops3 days ago

The auto column mapping is surprisingly accurate. Handles messy CSV headers well.

PM
pmdev1 week ago

Used this for our client data migration tool. The preview step gives users confidence.