2011-02-18 41 views
2

在默認bulkloader.yaml它曾這樣說:gae bulkloader將不會解析導入時的密鑰名稱?

# - Check that __key__ property is what you want. Its value will become 
#  the key name on import, and on export the value will be the Key 
#  object. If you would like automatic key generation on import and 
#  omitting the key on export, you can remove the entire __key__ 
#  property from the property map. 

所以我假設默認的實現:

- property: __key__ 
     external_name: key 
     export_transform: transform.key_id_or_name_as_string 

應該在我的CSV文件導入鍵列到沒有問題的數據存儲。但它似乎什麼都不做。 (其他列雖然解析得很好)

回答

1

我是對的,默認的工具就夠了。不需要import_transform。我無法分析鍵值,因爲無論包含哪個字段,csv文件中的第一列(包含鍵)都不能被解析。只需在第一列中設置一個虛擬列來解決問題。

@Calvin,對不起,我沒有儘快驗證你的答案。

2

您需要import_transform才能將密鑰獲取到數據存儲中。導出轉換是寫出到csv文件。

我不認爲有一個內置的轉換方法將字符串轉換回密鑰。

我寫了兩個輔助函數來處理導出和導入密鑰: key_to_reverse_str (export) and reverse_str_to_key (import) 當時的想法是保持價值人類可讀的出口,但需要保持進口的所有數據。它們可能對你有用。