npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

import-csv-form

v0.5.7

Published

csv file import form using mui

Downloads

74

Readme

Import CSV Form

GitHub Repository

Find the Import CSV Form repository on GitHub.

Overview

The Import CSV Form component simplifies the process of importing CSV files into your web application. It provides an easy-to-use interface for uploading CSV files and customizing their handling, including options for delimiters, qualifiers, and date formats.

Output

After submitting the form, the Import CSV Form component allows your frontend to send the data to your backend server. The backend can then manage the uploaded CSV file, along with specified parameters like delimiters and date formats. This facilitates smooth processing of CSV data, such as insertion into a database or other necessary manipulations on the server side.

Installation

To install the package, use npm:

npm install import-csv-form

Usage

Here's an example of how to use the ImportCsvDialog component in your React application:

import ImportCsvDialog from "import-csv-form";
import { useState } from "react";

function YourComponent() {
  const [openUploadFile, setOpenUploadFile] = useState(false);

  const handleCloseDialog = () => {
    setOpenUploadFile(false);
  };

  const handleImport = (data) => {
    // Your logic to send data to the backend
    // Example: Send data using fetch or axios
    fetch("your-backend-url", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify(data),
    })
      .then((response) => response.json())
      .then((result) => {
        // Handle response from the server
      })
      .catch((error) => {
        // Handle errors
      });
  };

  return (
    <div>
      <button onClick={() => setOpenUploadFile(true)}>
        Open Upload File Dialog
      </button>
      {/* here the implementation */}
      <ImportCsvDialog
        open={openUploadFile}
        onSubmit={handleImport}
        onClose={handleCloseDialog}
        fieldsToBeOrder={[
          { label: "Operation Date", value: "operationDate" },
          { label: "Value Date", value: "valueDate" },
          { label: "Description", value: "description" },
        ]}
      />
    </div>
  );
}

Props

| Name | Default Value | Type | Description | | ------------------ | ------------------------------------------ | -------- | --------------------------------------------------------------------------------------- | | open | - | boolean | Determines whether the dialog is open or closed. | | existDate | true | boolean | Indicates whether date-related fields will be displayed. | | existAmount | true | boolean | Indicates whether amount-related fields will be displayed. | | existOrderFields | true | boolean | Indicates whether fields order-related options will be displayed. | | firstAmountColumn | 'Credit' | string | The label for the first amount column. | | secondAmountColumn | 'Debit' | string | The label for the second amount column. | | onClose | - | function | Callback function to handle the closing of the dialog. | | onSubmit | - | function | Callback function to handle the submission of form data. | | fieldsToBeOrder | [] | string[] | An array of field labels specifying the order of fields. | | delimiters | See example below | object[] | An array of objects representing delimiter options with 'label' and 'value' properties. | | qualifiers | See example below | object[] | An array of objects representing qualifier options with 'label' and 'value' properties. | | datesFormats | See example below | string[] | An array of string representing date format options. | | exampleFile | See example below | any[][] | A 2-dimensional array representing an example CSV file structure with data and headers. |

Default Delimiters

[
  { label: "Comma", value: "," },
  { label: "Semicolon", value: ";" },
  { label: "Pipe", value: "|" },
  { label: "Colon", value: ":" },
  { label: "Space", value: " " },
  { label: "Period", value: "." },
  { label: "Hyphen", value: "-" },
  { label: "Underscore", value: "_" },
  { label: "Slash", value: "/" },
];

Default Qualifiers

[
  { label: "Double Quote", value: '"' },
  { label: "Single Quote", value: "'" },
  { label: "Backtick", value: "`" },
];

Default Date Formats

[
  "YYYY-MM-DD",
  "DD/MM/YYYY",
  "MM/DD/YYYY",
  "MMMM DD, YYYY",
  "DD MMMM, YYYY",
  "YYYY-MM-DD HH:mm:ss",
  "DD/MM/YYYY HH:mm:ss",
  "MM/DD/YYYY HH:mm:ss",
  "YYYY-MM-DDTHH:mm:ssZ",
  "dddd, MMMM DD, YYYY",
];

Default Example File

[
  [
    "first_column",
    "second_column",
    "third_column",
    "fourth_column",
    "fifth_column",
  ],
  ["DD-MM-YYYY", "DD-MM-YYYY", 120, undefined, "text"],
  ["DD-MM-YYYY", "DD-MM-YYYY", undefined, 500, "text"],
  ["DD-MM-YYYY", "DD-MM-YYYY", 790, undefined, "text"],
];

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.