Importing Dexterity content via CSV
I needed to turn a spreadsheet into a bunch of content items. Since there was nothing particularly specific about this, I made a generic blueprint that's hopefully useful for everyone.
- Ensure plone.app.transmogrifier and transmogrify.dexterity are in your buildout.cfg
- Create a CSV file called entries.csv, one line per content item
- Create a transmogrifier.txt file with the line "transmogrify.dexterity.csvimport".
- Tar both of them up into, say import.tar.gz
- Visit /Plone/portal_setup/manage_importSteps, choose the file and click "Import uploaded tarball".
That's great, but what goes in entries.csv?
There's one header row with column names, then each row represents a different content item. Generally each column will set the Dexterity field of the same name. There are special columns, namely:-
_type: portal_type of content (optional, default is Document)
_path: Full path to content item, including content ID.
_folder: Folder containing item, id will be derived from title
_transitions: Workflow transition (optional, default is "publish")
Either _path or _folder and title are required.
Lovely, but how do I use it to update images?
It's only a CSV file, don't get too excited. One could add a column that referenced files sitting alongside entries.csv, but this isn't something I tried to get going. If you are trying to update Lists / Choice fields, CSV just isn't going to work. Time to get a better data format.