Transpose CSV file (uncross a table)

I have a csv that I am taking from an SFTP server and it has the following format

ID1, Column1, Column2, ..., ColumnN

ID2, Column1, Column2, ..., ColumnN

I need to send this to another SFTP server and instead of csv it has to be a .txt file which I figured out on the flow.

my problem though is that the structure has to be different as well and I don't know how to accomplish this, the expected output should be:

ID1, Column1

ID1, Column2

...

IDN, ColumnN

How can I achieve this?

If anyone has some insight it's greatly appreciated , thanks!

@leonelreyes I would put a preSave page script on your export FTP. For the most part, I used Celigo AI to write the script, but added a more description output requirement.

function preSavePage (options) {
// sample code that simply passes on what has been exported
let modifiedData = [];
options.data.forEach(record => {
Object.keys(record).forEach(key => {
if (key !== 'Id') {
modifiedData.push({ id: record['Id'], value: record[key], field: key });
}
});
});

return {
data: modifiedData,
errors: options.errors,
abort: false,
newErrorsAndRetryData: []
};
}

Prompt:

my output should be an array of objects with 3 fields per object "id", "value", and "field" where id is the id, value is the value of the column field, and field is the key of the column field. I have a csv that I am taking from an SFTP server and it has the following format ID1, Column1, Column2, ..., ColumnN ID2, Column1, Column2, ..., ColumnN I need to send this to another SFTP server and instead of csv it has to be a .txt file which I figured out on the flow. my problem though is that the structure has to be different as well and I don't know how to accomplish this, the expected output should be: ID1, Column1 ID1, Column2 ... IDN, ColumnN How can I achieve this? If anyone has some insight it's greatly appreciated , thanks!