Tutorial: Import data to create a table

Learn how to import data to create a table in a feature service.

santa monica parcels table

Importing data is the process of using data management tools in your portal to upload a file to create a table in a feature service. Each file you import becomes a table in the service. A table is used to store only attributes; no geometry or locations fields are needed. After a table is created, applications can access it by using its ID or URL. You can also query, edit, and join the table to other features.

In this tutorial, you use data management tools and scripting APIs to import a CSV file of parcel attributes to create a table in a feature service.

Prerequisites

You need an account for ArcGIS Location Platform, ArcGIS Online, or ArcGIS Enterprise to create hosted data services. If you need an account, go to Get started.

Steps

Download the data

  1. Download the Santa Monica parcels table CSV file from ArcGIS portal.

Import the parcel information CSV file

The CSV file contains data with attributes containing parcel information, but no location (geometry or address) fields. Importing the file will create a new table in a feature service.

Follow the steps below to use Data management tools or Scripting APIs:

In your web browser, go to https://location.arcgis.com, and sign in with your ArcGIS Location Platform account. In the ArcGIS Location Platform dashboard, click My portal to go to your portal.

  1. In the top navigation bar, click Content.

  2. Click New item. To upload the Santa Monica Parcels Shapefile, you can either:

    • Drag and drop the file.
    • Or, click Your device and navigate to the file path.
  3. Select Add santa-monica-parcels.csv to publish the file as a hosted feature table.

  4. In Fields, leave all fields at their default settings and click Next.

  5. In Location settings, Select None under Specify the type of location information the file contains and click Next.

  6. Set the following information in the item details pane:

    • Title: Santa Monica parcel table
    • Tags: Santa Monica parcel,table,tutorial.
    • Summary: Parcel data for the City of Santa Monica
  7. Click Save to create the new table and feature service.

To access a hosted feature table from an application, you need to be able to identify its ID and URL. If a hosted feature table is public, you use the URL to access it directly with your web browser or any application. If the layer is private, you need to provide an access token.

Public: [https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_parcels_table/FeatureServer/0)

Private: [https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_parcels_table/FeatureServer?token=ACCESS_TOKEN)

  1. In the item page of the layer, find the Item ID and Point Layer URL. They should look something like this:
    • Layer ID: 84c6c48c754e4e26a886c54dbc1372d4
    • Point Layer URL: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Santa_Monica_parcels_table/FeatureServer/
  1. Import the required libraries.
  2. Implement authentication.
  3. Create and publish a portal item.
  4. Handle the results.
Expand
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# local path to csv file
input_file_path = str(Path(__file__).parent / "data/santa-monica-parcels.csv")

# add the csv file as an item to portal
csv_item = portal.content.add(
    {
        "title": "Santa Monica parcels table",
        "description": "Table imported from CSV file in Santa Monica",
        "tags": "Santa Monica, parcels, table, tutorial",
    },
    input_file_path,
)

# publish the item to create a hosted featurelayer
csv_service = csv_item.publish(None)

print(f"New item id : {csv_service.id}, url: {csv_service.url}")

You now have a table hosted in your portal. You can access it with its service URL or layer item ID in your applications. To manage your hosted layer (item) properties and capabilities, visit the Manage a feature layer tutorial.

What's next?

Learn how to use additional tools, APIs, and location services in these tutorials:

Define a new feature layer

Use data management tools to define and create a new empty feature layer in a feature service.


Manage a feature layer

Use a hosted feature layer item to set the properties and settings of a feature layer in a feature service.


Create a vector tile service

Use data management tools to create a new vector tile service from a feature service.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.