Item type'url' is not supported for anzlyzing

80
2
04-18-2020 07:30 PM
TezzyO_
New Contributor

Hi there,

I am simply following Analyze the source csv item on Append Features | ArcGIS for Developers.

Upon executing the below:

source_info = gis.content.analyze(item=ws_item.id,
file_type="csv",
location_type='none')
I get the following error on Jupyter Notebook. 
Unable to analyze item.
Item type'url' is not supported for anzlyzing, The item needs to be of type file

Somehow the analyze method is not taking in the earlier "type":"CSV" in: 

world_sov_props = {"title":"world_sovereignty_" + now_dt(),
"type":"CSV",
"tags":"indepedence, politics, international boundaries, geopolitics",
"snippet":"Data about the sovereignty of many of the world's nations",
"description":"Data collected from wikipedia regarding national sovereignty across the world"}

Has anyone encountered this problem?

Thanks,

Tags (2)
Reply
0 Kudos
2 Replies
JoshuaBixby
MVP Esteemed Contributor

I just tested the code snippet from the Guide and it works fine for me.

What version of ArcGIS API for Python on you using?

The error message indicates you are passing a URL instead of a text string containing the ID of the item.  Can you provide more code to show where ws_item is being defined?

Reply
0 Kudos
TezzyO_
New Contributor

Thanks Joshua.

arcgis                    1.6.0            py37h39e3cac_1    esri

Well, the code is exactly as per the doc:

ws_item = gis.content.add(item_properties=world_sov_props,  
data=country_csv,
folder="World Sovereignty")

 

I tried my own version as below, still the same error message at the analyze method:


import
ruamel.yaml as yaml
from arcgis.gis import GIS
import datetime as dt

time_stamp =dt.datetime.now().strftime('%Y%m%d%H%M%S%z')


with open("arcgis_login.yaml") as stream:  
try:
       arc_gis_login_dict = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print("YAML reading error")
gis = GIS(arc_gis_login_dict["dev_account"]['url'],  
arc_gis_login_dict["dev_account"]['username'],
arc_gis_login_dict["dev_account"]['password'])

folder_name = 'test'  
file_type = 'CSV'
full_path_name = !pwd
full_path_name = str(full_path_name[0]) + '/'
corona_virus_props = {"title":"Corona_Virus_"+time_stamp,  
"type":file_type,
"tags":"Corona Virus, World, Cases, Deaths",
"snippet":"Corona virus cases and deaths by country.",
"description":"Data downloaded from worldometers: COVID-19 \
Corona Virus Pandemic https://www.worldometers.info/coronavirus/"}

if not folder_name in [folder['title'] for folder in gis.users.me.folders]:
gis.content.create_folder(folder_name)


corona_virus_props_data_item = gis.content.add(item_properties=corona_virus_props,
data=full_path_name+joined_data_file_name,
folder=folder_name)


corona_virus_props_item = corona_virus_props_data_item.publish()

print(corona_virus_props_item.id)
#
'494864c45a004c09a1013f3af730d34d'
source_info = gis.content.analyze(item=corona_virus_props_item.id,  
file_type=file_type,
location_type='none')

By the way how can one format code properly?
StackOverflow has '{}' that nicely format the underlying code.
I tried Syntax highlighter, but it puts everything in one liner.
Reply
0 Kudos