How to organize and arrange data tables

Yashasvika Duggal
  • Updated

This article outlines ways to sort data both manually using the Terra UI and programmatically using the terminal to make it easier to work with. Workspace data tables are like integrated spreadsheets in the Data page that help to organize and keep track of all project data. Some data sets are so huge that it is useful to reorder how data is shown by default.

Sorting a column in ascending or descending order

A quick way to sort data is by ascending or descending order of individual columns.

1.1. Click the three vertical dots in the top right corner to open the column menu

1.2. Choose to sort columns by ascending or descending order. 


Note: If you double tap a column title, a small arrow will appear on the right corner of the column allowing you to change the column order.

Reorganizing columns using drag and drop 

The order of columns can be changed through the drag and drop column reorder feature.

2.1. Click the settings button near the top left page of the data tab in a workspace. 

2.2. Manually move the columns within the settings window to display in a different order.  


2.3. To rename and save, click save this column selection. You can use these column settings in copies of this workspace and when sharing with other users.

If you have multiple saved column selections you can toggle through the different selections using the settings button. 

Reordering columns using a TSV file

Display data columns in the same order as the TSV you use to upload the data to a table (rather than the default - alphabetical - order) following the directions below.

3.1. Click on workspace data on the bottom left side of the data page of a workspace. This will open a list of key-value pairs

3.2. Add a key-value pair for the desired order by clicking on the blue plus icon on the bottom right hand side.


3.3. Click the plus icon and add the name of your key into your Terra workspace.

Example key: workspace-column-defaults

3.4. Run the code below in a local terminal instance on your local machine to obtain the value associated with the key.

Code parameters (required)

  • The name of your key
  • your dataset
import csv
import json
files = ["things.tsv"]
tables = {}
for path in files:
    with open(path) as f:
        reader = csv.reader(f, delimiter="\t")
        header_row = next(reader)
        entity = header_row[0][len("entity:"):-len("_id")]
        tables[entity] = {
          "shown": [header_row[0][len("entity:"):]] + header_row[1:],
          "hidden": []
workspace_column_defaults = json.dumps(tables)

3.5. Add the value from the code into Terra and save changes. 


3.6. Upload the data as a .TSV. It will appear in the key-value pair order instead of in random order. 


The following is an example where the key value has been set as 'workspace-column-order' and the dataset has been saved on the local machine as 'things.tsv'


In this example our value is:  {"sample": {"shown": ["sample_id", "height", "ancestry", "sex", "age", "fg", "bmi", "fi", "hdl", "ldl", "population", "tc", "tg", "whr"], "hidden": }}

Troubleshooting key-value pairs

You must define key-value pairs prior to uploading data. When they are added after the data has already been uploaded, you may need to clear your local storage. 

1. Click the three dot menu on the upper right hand corner of the Google Chrome browser to access the developer tools on Google Chrome.

2. Click more tools and developer tools.

The hot keys to get to developer tools Mac OS Command + Option + I
Windows/Linux F12 or Control + Shift + I

3. On the top of the developer tab there is a menu with two arrows at the top, use the arrows to get to the application tab. 


4. On the application tab, go to local storage on the left-hand dashboard

5. From the local storage, delete all storage below apc_user_id. 


Deleting the local storage will allow you to "reset" the order of data on Terra without needing to re-upload the dataset. 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request



Please sign in to leave a comment.