3

I've been using appcfg.py to upload_data pretty successfully, but I'm not sure how to set up the import transform in bulkloader.yaml for repeated properties or how to structure the CSV. For example:

In a post model that looks like this:

class Post(models.Model):
  tags = ndb.StringProperty(repeated=True)

and a bulkloader.yaml looks like this:

transformers:
- kind: Post
  connector: csv

  property_map:
    - property: __key__
      external_name: key
      export_transform: transform.key_id_or_name_as_string
    - property: tags
      external_name: tags
      import_transform: ???

is import_transform the right API to register for this? Or is there some other way to do this?

mehulkar
  • 4,895
  • 5
  • 35
  • 55

1 Answers1

1

I've tried a two step approach that seems to work using the import_transform. First create a module (essentially a custom transform file), let's say bulkmodify.py. Then in bulkmodify define a transform converting the incoming value to a list

def list_convert(value):
    output=[value]
    return output

Then in your bulkloader.yaml file specify the import transform for your repeated property:

import_transform: bulkmodify.list_convert

Also don't forget to include your module in the import list at the top of your bulkloader.yaml file.

- import: bulkmodify

In my input CSV the data is structured with multiple quotes so the bulkloader brings them in as a single property with multiple listed values

key,"""tag1"",""tag2"",""tag3""", property3, etc.
StuAustin
  • 11
  • 1