Skip to main content

Append data to table

Use this API to add data in bulk to an existing table. If you need to add columns, you can also add the configuration information corresponding to the columns in the json saved in the columns file (see Create table API).

Request

curl -vvv -X POST "$API_HOST/open/api/v1/tablenodes/$table_id/rows/append/" -H "Authorization: $access-token" -d "skipFirstRow=false&autoCreateColumn=true" -F "columns=@$file_path" -F "rows=@$csv_file_path"

The request is submitted using a form that contains two fields: columns and rows, which represent the "table column definition" and "data rows" respectively. Refer to the table below for details.

Response body form-data example

KeyValueRequiredNote
skipFirstRowfalseNOSkip the csv deader
autoCreateColumnfalseNOCreate new columns( if a column has no id field in the config file)
columnsread_table_columns.jsonYESColumns configuration file. The columns should keep the same order as columns in csv file.
rowsgd_append.csvYESNew rows

column parameters json format description

KeyTypeDescriptionRequired
arraycolumn listY
∟ idstringcolumn IDY, blank if user want to add a new column
∟ namestringColumn NameYes if new column
∟ typestringcolumn type:multiLineText number datetime singleChoice coordinateYes if new column
∟ typeOptionsobjectcolumn options:When column is number, datetime, or singleChoiceN
∟ formatstringnumber type:number, percentage, commaNumberYES:When number type
∟ precisionstringprecision: 0-5YES:When number type
∟ dateFormatstringdate format: year/month/day month/day/year detailYES:When datetime type
∟ timeFormatstringtime format: hidden 24-hour-clock 12-hour-clockYES:When datetime type
∟ choicesarrayoption list: created automatically when emptyYES:When singleChoice type
∟ namestringoption nameYES:When singleChoice type
∟ colorstringoption color: use a random color when emptyYES:When singleChoice type

Python example

def table_append_data(access_token, table_id, data, columns_file, data_file):
url = '%s/open/api/v1/tablenodes/%d/rows/append/' % (API_HOST, table_id)
files = {'rows': open(data_file, 'rb'),
'columns': open(columns_file, 'rb')}
headers = {'Authorization': access_token}
req = requests.post(url, data=data, headers=headers, files=files)
return req.json()

# create table using csv
data = {
'projectID': project['id'],
'name': 'test-csv-upload',
'skipFirstRow': True
}
resp = ma.create_table(access_token, data,
'data/create_table_columns.json',
'data/gd.csv')

table = resp['detail']
resp = ma.read_table(access_token, table['id'], '', '')
with open('data/read_table_columns.json', 'w') as f:
json.dump(resp['detail']['columns'], f)

data = {
'skipFirstRow': True,
'autoCreateColumn': False
}

resp = ma.table_append_data(access_token, table['id'],
data,
'data/read_table_columns.json',
'data/gd.append.csv')

Response

Response body

Description of some key information

KeyTypeDescription
detailobjectResponse boject
∟ idint64Table ID
∟addedColumnsarrayAdded columns (if new columns added)
∟ idstringColumn ID
∟ typestringColumn type
∟typeOptionsobjectColumn options
∟ isPrimarybooleanIs primary column
∟appendRowIDsmapNew row IDs

Response body example

{
"code": 0,
"detail": {
"id": 980,
"name": "newName2",
"type": "table",
"order": 441,
"parentID":null,
"projectID": 264,
"subscribed":false,
"published":false,
"roleInherited":true,
"createTime": "2022-04-15T06:44:21.506295Z",
"updateTime": "2022-04-15T06:48:33.243726Z",
"addedColumns": [
{
"id": "625914457cff69c01aed2d71",
"name": "New-Title1",
"type": "multiLineText",
"typeOptions":null,
"isPrimary":true }
],
"appendRowIDs": {
"0": "625931df04b5540935aef0dd",
"1": "625931df04b5540935aef0de"
},
"importErr":null },
"extra":null,
"message": "OK",
"requestID":null
}