Closed irborrero closed 3 years ago
Hi @irborrero,
That's correct, you can use the transformRows
callback in the options, which returns a Promise containing the transformed rows. Yours might look like:
const options = {
transformRows: (csvRows) => {
const newRows = []; // new rows here!
return newRows;
}
}
You could also modify your Dataprovider to handle this too. Let me know how you go :) Ben
Hi @benwinding
Yes it worked!
Did this:
const config: ImportConfig = {
transformRows: (csvRows: any[]) => {
const transformedCsvRows = [];
csvRows.map((row) => {
row.companyId = companyId;
transformedCsvRows.push(row);
});
return transformedCsvRows;
},
};
Thanks :)
Hello,
First of all, thank you for this feature! It really saves a lot of time.
Here is my use case:
I am importing a csv file that looks like this:
I would like to add an extra CSV field before posting, so that the post request payload looks like this:
The additional field is always a constant value that I need to send to my API endpoint to perform the post request.
Is it possible to achieve this with transform rows in config? Has anyone tried to do this before?