Import GeoPt data using Google AppEngine BulkLoader YAML

I am loading data from a csv file with a GeoPt column in it. I have the GeoPt column data in quotation marks as follows: SomeData, "54.321, -123.456", MoreData p>

There is an entry in my bulkloader.yaml file: - property: location external_name: LOCATION # Type: GeoPt Stats: 1 properties of this type in this way.

When I do the download and go to the DataStore viewer, I see that the location was loaded as a string instead of GeoPt. I'm not sure what the correct import method will be. Perhaps this requires import_transform?

+2
source share
2 answers

Create the uploadutil.py file and add this method to it:

 def geo_converter(geo_str): if geo_str: lat, lng = geo_str.split(',') return db.GeoPt(lat=float(lat), lon=float(lng)) return None 

Then add this to bulkloader.yaml :

Add import for uploadutil:

 - import: uploadutil 

And add property:

 - property: location external_name: LOCATION import_transform: uploadutil.geo_converter 
+4
source

If you load NameError global name 'db' is not defined during data loading, add the line

  from google.appengine.ext import db 

to uploadutil.py

+3
source

All Articles