Select to view content in your preferred language

AGOL Notebook webtool parameters

338
3
08-14-2024 12:10 PM
HaydnLawrenceMoncton
New Contributor

I am trying to get the item id from a "File" input parameter in my AGOL notebook's published webtool. The CSV is brought in no problem as I can access it, get the data, and output a new CSV. However, I have manually added the itemID to my code and would rather be able to access it from the input parameter of the chosen CSV. 

I know it's probably a quick answer, but can't find it in the documentation. 

Also, if anyone knows how to send output to the final results window of a webtool in AGOL similar to how arcpy.AddMessage does for a normal geoprocessing tool, that would be great. 

My variable is added to the notebook:
data_csv = {
  "dataType": "GPDataFile",
  "paramName": "data_csv",
    "value": {
    "url": ""
  }
}

 

And right now I am just using this itemid hardcoded to access and download the file to put in a pandas dataframe. What I would like is something like "data_csv.value.itemid" or something similar instead of the hardcoded itemid value.

item_id = '38f3XXXXXXXX...'
item = gis.content.get(item_id)
csv_data = item.download(file_name='data.csv')

# Load the CSV into a Pandas DataFrame
with open(csv_data, 'r') as file:
  data_pd = pd.read_csv(file)
  print(data_pd.head())

 


Thanks!

0 Kudos
3 Replies
Clubdebambos
Frequent Contributor

Hi @HaydnLawrenceMoncton,

Any chance you could share some of the code for troubleshooting?

Cheers,

Glen

~ learn.finaldraftmapping.com
0 Kudos
HaydnLawrenceMoncton
New Contributor

My variable is added to the notebook:
data_csv = {
  "dataType": "GPDataFile",
  "paramName": "data_csv",
    "value": {
    "url": ""
  }
}

 

And right now I am just using this itemid hardcoded to access and download the file to put in a pandas dataframe. What I would like is something like "data_csv.value.itemid" or something similar instead of the hardcoded itemid value.

item_id = '38f3XXXXXXXX...'
item = gis.content.get(item_id)
csv_data = item.download(file_name='data.csv')

# Load the CSV into a Pandas DataFrame
with open(csv_data, 'r') as file:
  data_pd = pd.read_csv(file)
  print(data_pd.head())

 

Clubdebambos
Frequent Contributor

I also could not get the WebTool to take a CSV item as input or a url to a CSV file and directly access the item/csv data from the input parameter.

~ learn.finaldraftmapping.com
0 Kudos