Select to view content in your preferred language

How to use Python API to export Online Feature Class as CSV?

4589
4
Jump to solution
04-20-2018 06:22 AM
GeorgeClutterbuck
Occasional Contributor

Hi,

I'm currently using the ArcREST API to download a feature class stored online as a CSV but I know that this is deprecated and the Python API is supposed to replace it. Can anyone offer any solutions for how to use the new API to download the attributes of a feature class in CSV format?

I have attempted this (How To: Create and download a file geodatabase replica from a hosted feature service using Python ) but it doesn't seem to work and also it seems to only offer gdb as the output whereas I need CSV.

Hope someone can help!

Thanks

0 Kudos
1 Solution

Accepted Solutions
MattiasWallin
Occasional Contributor

Not sure if I understand the problem correct but have you tried using the Spatial DataFrame?

This works for me:

Save to .CSV example

View solution in original post

4 Replies
MattiasWallin
Occasional Contributor

Not sure if I understand the problem correct but have you tried using the Spatial DataFrame?

This works for me:

Save to .CSV example

GeorgeClutterbuck
Occasional Contributor

Hi Mattias,

I'm not sure if can help but since the update to ArcGIS Pro 2.2 and the latest Python 3, your method is now broken for me... the line:

sdf = ethosequip.layers[0].query().df

produces:

ValueError: Invalid geometry type for method

The method still works on a pc that I haven't updated to the latest python... bit concerning that a minor python update seems to have broken it. I have been trying to figure out why but am drawing a blank. Any help would be great. I am also trying to use the export function but having no joy (arcgis.gis module — arcgis 1.4.2 documentation )

Thanks,

Luke

0 Kudos
MattiasWallin
Occasional Contributor

Hi Luke,

I just installed Pro 2.2 and the code still works for me. It looks like 2.2 comes with the 1.4.1 API version- did you upgrade to 1.4.2?

Mattias.

0 Kudos
GeorgeClutterbuck
Occasional Contributor

Hi Mattias,

That's odd, it doesn't work on any of our computers running 2.2... I was running api version 1.4.1, i upgraded it to 1.4.2 today and it still creates the same error. It's very frustrating error and all the more if the script is working fine on your 2.2!

Luke

0 Kudos