Last active
September 11, 2018 10:12
-
-
Save maethu/41eeb51cf18087cc0f9bfc7533eecbb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> plone = app.platform | |
>>> from zope.component.hooks import setSite | |
>>> setSite(plone) | |
>>> from plone import api | |
>>> import csv | |
>>> from StringIO import StringIO | |
>>> handler = open('user.csv', 'r') | |
>>> data = handler.read().decode("utf-8-sig").encode("utf-8") | |
>>> csv_data = csv.DictReader(StringIO(data), delimiter=';') | |
>>> for item in csv_data: | |
... props = dict(fullname='{} {}'.format(item['vorname'], item['nachname'])) | |
... try: | |
... api.user.create(username=item['benutzername'], email=item['email'], password=item['passwort'], properties=props) | |
... except: | |
... print "Cannot create {}".format(item['benutzername']) | |
... | |
>>> import transaction | |
>>> transaction.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment