Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't Parse CSV in Plone 4
    text
    copied!<p>I am trying to batch load some dummy content from a CSV file into a development site to do some testing. I'm using Plone 4.0.1, with Python 2.6.5, on a Mac OS X 10.6.6. </p> <p>1) I thought I would create a quick script that would iterate through a CSV file and then create some of my custom contenttypes: (Similar to <a href="http://plone.org/documentation/kb/batch-adding-users" rel="nofollow">http://plone.org/documentation/kb/batch-adding-users</a>). In Plone 3, I had been able to parse CSV files in this fasion.</p> <p>However, I got an AttributeError on split. I'm copying from my ipython (ipzope) testing:</p> <pre><code>&gt;&gt;&gt; portal &lt;PloneSite at /Plone&gt; &gt;&gt;&gt; portal['Scripts']['dummydata.csv'] &lt;File at /Plone/Scripts/dummydata.csv&gt; &gt;&gt;&gt; dummy = portal['Scripts']['dummydata.csv'] &gt;&gt;&gt; dummy &lt;File at /Plone/Scripts/dummydata.csv&gt; &gt;&gt;&gt; dummy.data.split('\n') ------------------------------------------------------------ Traceback (most recent call last): File "&lt;ipython console&gt;", line 1, in &lt;module&gt; AttributeError: split &gt;&gt;&gt; dummy.split('\n') ------------------------------------------------------------ Traceback (most recent call last): File "&lt;ipython console&gt;", line 1, in &lt;module&gt; AttributeError: split </code></pre> <p>2) Ultimately, I'd like to use csv from the standard library, which also did not work.</p> <pre><code>&gt;&gt;&gt; import csv &gt;&gt;&gt; csv &lt;module 'csv' from '/Applications/Plone/Python-2.6/lib/python2.6/csv.pyc'&gt; &gt;&gt;&gt; spamReader = csv.reader(dummy, delimiter=',', quotechar='"') ------------------------------------------------------------ Traceback (most recent call last): File "&lt;ipython console&gt;", line 1, in &lt;module&gt; TypeError: argument 1 must be an iterator &gt;&gt;&gt; spamReader = csv.reader(dummy.data, delimiter=',', quotechar='"') ------------------------------------------------------------ Traceback (most recent call last): File "&lt;ipython console&gt;", line 1, in &lt;module&gt; TypeError: argument 1 must be an iterator </code></pre> <p>Any ideas?</p> <p>Best, Patrick</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload