Importing a List with BulkLoader

Fri, Jun 18, 2010

Tech Tips

The latest bulkloader script (api version 1.3.4) does a much better job of exporting data when you auto generate a .yaml file. However it doesn’t handle the re-import of lists by default (it just treats them as strings). You can add an inline lambda function to the .yaml file to fix this. This handles lists of strings, but it can probably be modified to handle other types.

– property: mylist
external_name: mylist
import_transform: “lambda x: len(x) > 0 and eval(x) or ””

Why it works:
In your csv, your list should export like so:
“[u’item1′, u’item2′, u’item3′]”
Running an eval on this string, converts it to a list. The length check is like if/else statement, if len(x) > 0 convert it else use empty string.

Bookmark and Share
,

2 Responses to “Importing a List with BulkLoader”

  1. E.T.Cook Says:

    This is slightly different than the google recommended (string split with lambda) method, but brilliant nonetheless!

  2. Backlinks Says:

    This blog was unbelievably helpful. Your the man. lol :)