Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FeatureSet.save() to CSV - TypeError #122

Closed
markegge opened this issue Jul 11, 2017 · 1 comment
Closed

FeatureSet.save() to CSV - TypeError #122

markegge opened this issue Jul 11, 2017 · 1 comment

Comments

@markegge
Copy link

I have a FeatureSet that I would like to save to CSV. One approach I've tried is to use the FeatureSet save() method. Unfortunately, attempting to save as a CSV produces a >> error. (Saving as a JSON file works just fine.)

Works (JSON)

In [14]: feature_set.save('data_folder', 'my_data.json')
Out [14]: 'data_folder/my_data.json'

Does not work (CSV)

In [15]: feature_set.save('data_folder', 'my_data.csv')
Out [15]: 
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<timed eval> in <module>()

/Users/markegge/anaconda3/envs/arcgis/lib/python3.6/site-packages/arcgis/features/feature.py in save(self, save_location, out_name)
    690                 # write the headers to the csv
    691                 for field in self.fields:
--> 692                     fields.append(field['name'])
    693                 csv_writer.writerow(fields)
    694 

TypeError: string indices must be integers

Using Python 3.6, ArcGIS API for Python version 1.2.0.

@achapkowski
Copy link
Contributor

@markegge
For later versions, the FeatureSet supports SpatialDataFrames.

So if you do FeatureSet.df.to_csv(out_path) you can save the FeatureSet to a csv file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants