Select to view content in your preferred language

ArcGIS API for Python Error

3563
5
02-20-2019 01:29 PM
GregThistle
Emerging Contributor

I am trying to query and download a feature layer in AGOl using the ArcGIS API for python. My code is as follows:

import arcgis
from arcgis.gis import GIS
gis = GIS("https://arcgis.com", "Username", "Password")
from arcgis.gis import *
import os
icy_conditions = gis.content.get('a6be839d462d4441802abad0728cc857')
icy_layers = icy_conditions.layers
icy_reports = icy_layers[0]
Status_query = icy_.query(where="Status='Cleared'")
output_file = Item.export(title=icy_reports,export_format="CSV",parameters=Status_query)

On the last line, I get an error saying:

Traceback (most recent call last):
File "<string>", line 10, in <module>
TypeError: export() missing 1 required positional argument: 'self'

I'm not sure where I have to call this argument. Could anyone help?

Thank you!

0 Kudos
5 Replies
EarlMedina
Esri Regular Contributor

Hi Greg,

Seems like this approach would also work for your use case: https://community.esri.com/thread/213402-how-to-use-python-api-to-export-online-feature-class-as-csv 

0 Kudos
Katie_Clark
MVP Alum

Greg,

I am still very new to writing python, but I wonder if the issue is that you didn't instantiate a class instance. Maybe these links could help you. The first one in particular has a very similar code snippet to yours:

How do you export a public service item from another organization?  

python - TypeError: Missing 1 required positional argument: 'self' - Stack Overflow 

arcgis.gis module — arcgis 1.5.3 documentation  

I don't see you initiate Item anywhere. Hope that helps or at least points you towards the right direction! As someone who's still learning, I'd appreciate if you could share the code snippet once you get it to work so I can see what fixes it

Best,
Katie

If this answer helped you, please consider giving a kudos and/or marking as the accepted solution. Thanks!
GregThistle
Emerging Contributor

Katherine,

That first link was exactly what I needed. The modified code is as follows:

import arcgis
from arcgis.gis import GIS
gis = GIS("https://arcgis.com", "Username", "Password")
from arcgis.gis import *
import os
icy_conditions = gis.content.get('a6be839d462d4441802abad0728cc857')
icy_layers = icy_conditions.layers
icy_reports = icy_layers[0]
Status_query = icy_.query(where="Status='Cleared'")
output_file = icy_conditions.export(title=icy_reports,export_format="CSV",parameters=Status_query) 

instead of item. I hadn't used the correct term when calling the export function as a mistook 'Item" for a module name. New to this as well, so thank you for sharing that!

Katie_Clark
MVP Alum

Awesome, glad it worked!

Best,
Katie

If this answer helped you, please consider giving a kudos and/or marking as the accepted solution. Thanks!
0 Kudos
GraceChukwu
New Contributor

hi,

how can i solve this error type, i was trying to train a model on ArcGIS Pro environment

TypeError: prepare_data() missing 1 required positional argument: 'class_mapping'

0 Kudos