问题描述
我正在从一个csv文件上传数据,其中包含一个GeoPt列。我有GeoPt列数据引用如下:SomeData,54.321,-123.456,MoreData
我的bulkloader.yaml文件有这样一个条目:
- property:location
external_name:LOCATION
#类型:GeoPt Stats:这种类型的属性有一个。
上传并转到DataStore查看器我看到该位置已上传为字符串而非GeoPt。我不确定导入它的正确方法是什么。也许它需要一个import_transform?
创建一个 uploadutil.py
文件并在其中添加此方法:
def geo_converter(geo_str):
如果geo_str:
lat,lng = geo_str.split( ',')
return db.GeoPt(lat = float(lat),lon = float(lng))
return None
然后将其添加到 bulkloader.yaml
:
添加导入for uploadutil:
- import:uploadutil
并添加属性:
- property:location
external_name:LOCATION
import_transform:uploadutil.geo_converter
I am uploading data from a csv file with a GeoPt column in it. I have the GeoPt column data in quotes like this: SomeData,"54.321,-123.456",MoreData
My bulkloader.yaml file has an entry like this: - property: location external_name: LOCATION # Type: GeoPt Stats: 1 properties of this type in this kind.
When I do the upload and go to the DataStore viewer I see the location has been uploaded as a string instead of a GeoPt. I'm not sure what the proper way to import this would be. Perhaps it requires an import_transform?
Create a uploadutil.py
file and add this method in 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 in bulkloader.yaml
:
Add import for uploadutil:
- import: uploadutil
And add property:
- property: location
external_name: LOCATION
import_transform: uploadutil.geo_converter
这篇关于使用Google AppEngine BulkLoader YAML导入GeoPt数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!