# Transpose CSV file (uncross a table)

**URL:** <https://connective.celigo.com/t/transpose-csv-file-uncross-a-table/106>\
**Category:** Integrator.io\
**Tags:** csv, transformation, file-transfer\
**Created:** [June 13, 2024, 2:13pm UTC](https://connective.celigo.com/t/transpose-csv-file-uncross-a-table/106 "2024-06-13T14:13:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonelreyes](https://avatars.discourse-cdn.com/v4/letter/l/71e660/32.png) [@leonelreyes](https://connective.celigo.com/u/leonelreyes)\
**Post date:** [June 13, 2024, 2:13pm UTC](https://connective.celigo.com/t/transpose-csv-file-uncross-a-table/106/1 "2024-06-13T14:13:16Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [June 13, 2024, 2:27pm UTC](https://connective.celigo.com/t/transpose-csv-file-uncross-a-table/106/2 "2024-06-13T14:27:06Z")

</div>

@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.

 ![5301043caa20740200000001-3bfc3f5faef849e5a16d42492ac827c0.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/3/347626a59a81d482ba5e92de64c660bc260ccd3c.png)

```
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!
