Select to view content in your preferred language

How to publish a Microsoft Excel to hosted Table using ArcGIS API for Python?

1283
2
07-23-2018 05:52 PM
Chai-YuanLiu
New Contributor

Ihave upload into a Microsoft Excel on portal,I want to publish it to a hosted Table.
If I use Item.publish() it will be ValueError,what should I do?


csv_file = 'D:/Test.csv'
csv_properties={'type':'Microsoft Excel','title':'Test','tags':['Test','Excel']}

csv_item = gis.content.add(csv_properties, None, None, None, None,'Test_Folder')

Tags (1)
0 Kudos
2 Replies
MunachisoOgbuchiekwe
Regular Contributor

Hello Chai-Yuan Liu, 

If you want to publish a csv to portal you can do the following....

import arcgis
import json
from arcgis.gis import GIS


gis = GIS(None,'username', 'password', verify_cert=False)


try:
    # Path to the CSV file
    pathToFile = r'path to file'
    # Add the CSV file to portal.
    item = gis.content.add({'title': 'testcsv'}, pathToFile)
    # If you want the table as a hosted feature layer then publish the item
    item.publish()
except Exception as e:
    print(e)
0 Kudos
GonzalezMorales
Emerging Contributor

How could I publish the table as a hosted table instead of a hosted feature layer?

Tags (1)
0 Kudos