Khoi
Khoi

Reputation: 4635

gae bulkloader won't parse key name on import?

in the default bulkloader.yaml it said this:

#    - 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.

so I assume the default implementation:

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

should import the key column in my csv file into the datastore with no problem. However it appear to do nothing. (other columns were parsed fine though)

Upvotes: 2

Views: 397

Answers (2)

Khoi
Khoi

Reputation: 4635

I was right on that the default implement was enough. No import_transform was needed. I couldn't parse key value because the first column in the csv file (which contained the keys) could never be parsed no matter which field it contains. Simply place a dummy column as the first column fixed the problem.

@Calvin, sorry I didn't validate your answer sooner.

Upvotes: 1

Calvin
Calvin

Reputation: 4195

You need an import_transform to get the key into the datastore. The export transform is for writing out to the csv file.

I don't think there's a built-in transform method to turn a string back into a key.

I wrote two helper functions for dealing with exporting and importing keys: key_to_reverse_str (export) and reverse_str_to_key (import) The idea was to keep the value human readable on exporting, but keep all data needed for import. They might be useful for you.

Upvotes: 2

Related Questions