Skip first three rows of CSV on import?
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
-
Huge thx!! This is perfect.
Answers
-
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 filtercsv_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
}
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback