Append data from csv to hosted table using Python API

03-30-2020 07:14 AM
New Contributor III

I would like to append data to a hosted Table from a csv file using the Python API.

This can be done in AGOL, by choosing Update Data -> Append data to layer, how would that be done in Python.

I've tried to follow this: Append Features | ArcGIS for Developers 

When I try to append the table using:

dataset_tbl.append(item_id=new_csv_item_id, upload_format='csv')

I get an error message "Unable to append data. Missing appendSourceInfo parameters.

I see that I should enter something here, but I'm not sure what.


optional dictionary. This is only needed when appending data from excel or csv. The appendSourceInfo can be the publishing parameter returned from analyze the csv or excel file.

Note that this table has no geometry, it is a data table only. Also this table is joined, so it cannot be overwritten.  

0 Kudos
5 Replies
Esri Esteemed Contributor

Hi Jean-Sebastien,

You can use ArcGIS Pro's Append tool to do this.  If you initially run into issues with the CSV as the input table, you may want to try converting it to a geodatabase table, and then using this as the input for the Append.

0 Kudos
New Contributor III

I just got it to work by feeding in the result of gis.content.analyze as the source_info argument

param1 = gis.content.analyze(



Occasional Contributor

What is the content or correct form of the content of the variable dataset_tbl.

I tried the following three:


oldcsv = gis.content.get(tbl)  where the tbl is the item id?

response "item object has no attribute 'append'"


oldcsvFLC = FeatureLayerCollection.fromitem(oldcsv)?

response  'FeatureLayerCollection' object has no attribute 'append'


tbl = oldcsvFLC.tables

response "append() takes no keyword arguments"

My source data is a csv file loaded into AGOL.

My target table (oldcsv) is a hosted table on AGOL.


0 Kudos
New Contributor III

Assuming you have a hosted table on AGOL that you want to update using a csv file already uploaded on AGOL. This is what I do. Replace {} by your file/id.

para1=gis.content.analyze(item='{your new csv ID}')

ExistingData= gis.content.get({ID of your hosted table on AGOL)

dataset_tbl = ExistingData.tables[0]

dataset_tbl.append(item_id = {your new csv ID}, upload_format = 'csv', source_info = para1, upsert=False)

I hope that helps

Occasional Contributor

Thank you very much.  It worked like a charm.  

0 Kudos