0

I have been struggling with Papaparse and Ag grid for a few days now. I've met a wall and I don't know too much if I have any options. Therefore, I am very much asking you guys for help.

Is it possible for Papaparse-react to parse my CSV file in such a way that it automatically skips the first 9 rows and 1 column on the left, and the last 2 columns on the right? In my company, the program to generate CSV files automatically adds these unnecessary things.

Currently, I just came up with an option with adding to config setData(results.data.slice(9). I don't know if this is the right way to do it, I'm really asking for your advice.

function CSVParse() {
  const [data, setData] = useState([]);

  const handleFileUpload = (event) => {
    const file = event.target.files[0];

    Papa.parse(file, {
      header: true,
      dynamicTyping: true,
      skipEmptyLines: true,
      complete: (results) => {
        setData(results.data.slice(9));
      },
    });
  };

While what I want to achieve is possible, I would then like to read the array of objects prepared in this way using Ag Grid to generate a simple table with 2 columns.

0 Answers0