Appending data to a table

In some cases, you may want to add data to an already existing table, there are a few methods to achieve this.

Add data using the UI

This method of adding data to existing tables is useful when tables are small and the data to be added is minimal.

Start by navigating to the Database table tab and finding the table you need to add data to. Go to the table's menu and select Analyse data or open the table and select Analyse data from the menu bar at the top. Your table should open in a new tab.

At the bottom of the table, select the "+ Rows" button which will add a new row to your table. Fill in the new data and click the Green *"Save" * button on the bottom right of the screen.

Your new data has now been added to the table.

This method can also be used to add new columns to your table using the "+ Column" button.

Adding data using a script

Data can also be added to tables using a script. We have provided an example here in python but you could equally create one in R and run it in the console or add data using a SQL statement and the built-in SQL editor.

The following script can be run as a background job or in a workspace app in order to append data to existing DB tables.

In the example, replace the variable csv_path with the csv file that contains the data to append and table_name with the name of the destination table.

This script was last tested ay Aridhia in October 2025.

import psycopg2
 
# === 1. Database connection parameters ===
conn = psycopg2.connect()
 
# === 2. Open a cursor ===
cur = conn.cursor()
 
# === 3. Append CSV data to the existing table ===
csv_path = "/home/workspace/files/iris_extra_data.csv"
table_name = "iris"
 
with open(csv_path, 'r') as f:
    # Skip header line if needed
    next(f)
    cur.copy_expert(f"COPY {table_name} FROM STDIN WITH CSV", f)
 
# === 4. Commit and close ===
conn.commit()
cur.close()
conn.close()
 
print("Data appended successfully!")

Adding data from a new csv

Data can also be uploaded to a workspace and automatically added to an existing table using the data upload functionality. In order to follow this method, you must have your new data in a csv file with a matching tdf(xml) metadata file. The xsd can be acquired from Aridhia if needed or use the "export metadata" function on the table; this will give you the tdf for the table you are trying to add data to.

Edit your tdf file with "Action=append" in the DatasetDefiniton field; it may look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<DatasetDefinition Action="append" TableName="append_test">
  <Title>Datatable append</Title>
  <Url/>
  <Description/>
  <Columns>
    <Column Name="hospital_name" Description="" Label="hospital_name" Type="text"/>

...

You can now use an upload token to upload both your csv and tdf tile. Make sure to select the option to "Upload to database".

Please ensure you upload your .xml file slightly before the .csv file otherwise the csv to data table process might start processing the .csv file by itself

The tdf metadata file can be reused with a new csv to upload more data if needed.

Updated on October 14, 2025

Was this article helpful?