---
title: "Add data from CSVs with different column orders"
excerpt: "Add data to a Data Source from a CSV, even if the columns are in a different order to the one used when the Data Source was created."
authors: "Pablo Marcos"
categories: "Product updates"
createdOn: "2023-09-25 00:00:00"
publishedOn: "2022-01-31 00:00:00"
updatedOn: "2025-04-24 00:00:00"
status: "published"
---

<p>Some of our users explained that sometimes the column order in CSV data files they wanted to add to a Data Source was not consistent with the column order in the Data Source. This resulted in data going into quarantine.</p><p>We improved Tinybird so that even if the columns are in a different order to the one used when the Data Source was created, you can add data to a Data Source from a CSV, provided, of course, that all the column names are in the CSV header.</p><p>Let’s look at an example of appending data to a exiting Data Source of movie likes and dislikes. The original Data Source was created from a CSV with this column order:</p><figure class="kg-card kg-embed-card"><iframe loading="lazy" width="100%" src="https://snippets.tinybird.co/endpoint?code=id%2Ccategory%2Cviews%2Clikes%2Cdislikes%2Ctimestamp%0A64488%2Cdrama%2C38288%2C1418%2C208%2C2022-01-27%2012%3A02%3A21.130022%0A340152%2Cdrama%2C125393%2C887%2C94%2C2022-01-27%2012%3A02%3A40.130007%0A951986%2Cromance%2C410826%2C978%2C42%2C2022-01-27%2012%3A02%3A47.129962%0A&amp;language=shell&amp;title=movies.csv&amp;run=&amp;token="></iframe></figure><p>Depending on the source of the data and how the CSVs are generated, the order of the columns might not be guaranteed. You could very well find a CSV with the same columns in different order:</p><figure class="kg-card kg-embed-card"><iframe loading="lazy" width="100%" src="https://snippets.tinybird.co/endpoint?code=timestamp%2Ccategory%2Cviews%2Clikes%2Cdislikes%2Cid%0A2022-01-27%2019%3A43%3A06.833582%2Ccomedy%2C64018%2C2425%2C125%2C810366%0A2022-01-27%2019%3A43%3A13.833689%2Cfantasy%2C137425%2C859%2C147%2C799473%0A2022-01-27%2019%3A43%3A28.833707%2Cfantasy%2C1321814%2C787%2C119%2C722195%0A&amp;language=shell&amp;title=movies.csv&amp;run=&amp;token="></iframe></figure><p>This is not a problem since the data will be appended correctly.</p><h3 id="append-from-the-ui">Append from the UI</h3><p>In the UI, to add data the new data to the movies Data Source just select add Data Source and upload the file named <code>movies.csv</code>, where the CSV header contains the column names.</p><figure class="kg-card kg-image-card kg-card-hascaption"><img src="https://tinybird-blog.ghost.io/content/images/2023/09/62539200924abb1a9c138359_append_data_in_ui-17.png" class="kg-image" alt="Appending data with reordered columns" loading="lazy" width="1936" height="1796" srcset="https://tinybird-blog.ghost.io/content/images/size/w600/2023/09/62539200924abb1a9c138359_append_data_in_ui-17.png 600w, https://tinybird-blog.ghost.io/content/images/size/w1000/2023/09/62539200924abb1a9c138359_append_data_in_ui-17.png 1000w, https://tinybird-blog.ghost.io/content/images/size/w1600/2023/09/62539200924abb1a9c138359_append_data_in_ui-17.png 1600w, https://tinybird-blog.ghost.io/content/images/2023/09/62539200924abb1a9c138359_append_data_in_ui-17.png 1936w" sizes="(min-width: 720px) 720px"><figcaption><span style="white-space: pre-wrap;">Appending data with reordered columns</span></figcaption></figure><p>The new data is appended to the movies Data Source.</p><h3 id="append-from-the-api">Append from the API</h3><p>From the API, to append data into the existing Data Source movies, you specify the <code>mode</code> and the <code>name</code>. The order of the columns doesn’t matter, provided the CSV header contains the column names.</p><figure class="kg-card kg-embed-card"><iframe loading="lazy" width="100%" src="https://snippets.tinybird.co/endpoint?code=curl%20%5C%0A-H%20%22Authorization%3A%20Bearer%20%3CDATASOURCES%3ACREATE%20token%3E%22%20%5C%0A-X%20POST%20%22https%3A%2F%2Fapi.tinybird.co%2Fv0%2Fdatasources%3Fmode%3Dappend%26name%3Dmovies%22%20%5C%0A-F%20csv%3D%40movies.csv%0A&amp;language=shell&amp;title=appending%20from%20the%20API&amp;run=&amp;token="></iframe></figure><h3 id="append-from-the-cli">Append from the CLI</h3><p>From the CLI, append the new data to the movies Data Source without worrying about the column order, provided the CSV header contains the column names.</p><figure class="kg-card kg-embed-card"><iframe loading="lazy" width="100%" src="https://snippets.tinybird.co/endpoint?code=%21tb%20datasource%20append%20movies%20movies.csv%0A%2A%2A%20%F0%9F%A5%9A%20starting%20import%20process%0A%2A%2A%20%F0%9F%90%A5%20done%0A%2A%2A%20Total%20rows%20in%20movies%3A%201500000%0A%2A%2A%20Data%20appended%20to%20Data%20Source%20%27movies%27%20successfully%21%0A%2A%2A%20Data%20pushed%20to%20movies%0A&amp;language=shell&amp;title=appending%20from%20the%20command%20line&amp;run=&amp;token="></iframe></figure><p><a href="https://www.tinybird.co/login" rel="noreferrer">Login</a> to your account to check this out and tell us what you think in our <a href="https://join.slack.com/t/tinybird-community/shared_invite/zt-yi4hb0ht-IXn9iVuewXIs3QXVqKS~NQ">Slack</a>.</p>
