Skip first three rows of CSV on import?

Options

I have a CSV that users will be uploading from a specific source that adds notes in the first three rows of the CSV. So, the in source CSV - the headers are in ROW 4.

If the first three rows can be deleted (or ignored) - then the file will upload perfectly to the existing table I have created. Is there a way that I can have XANO "ignore" the first three rows on import?? Or would I need to create some type of JS script to modify the file first?

Any ideas or thoughts most appreciated.

Best Answer

Answers

  • Lefteris - blupry.com
    Options

    Hello @Orbiter,

    There might be a slight possibility to achieve something like this using Xano.

    More specifically by using the filter csv_decode, then applying the necessary changes to that value to eventually use the filter csv_encode to get the updated CSV back.

    But despite the fact that this might not work, I strongly believe that you should update the CSV in your frontend application, since you mentioned you are able to use JS.

    This code snippet might be helpful:

    const fs = require('fs');

    function parseCSV(inputFilePath) {
    const fileData = fs.readFileSync(inputFilePath, 'utf-8');
    const rows = fileData.split('\n');

    const remainingRows = rows.slice(3);

    const remainingCSV = remainingRows.join('\n');

    return remainingCSV;
    }

    const inputFilePath = 'path/to/your/csv/file.csv';

    try {
    const remainingCSV = parseCSV(inputFilePath);
    } catch (error) {
    //Handle error
    }