<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 12/11/12 8:15 PM, Gregory Pittman
wrote:<br>
</div>
<blockquote cite="mid:50C7864A.1050807@iglou.com" type="cite">On
12/11/2012 03:33 AM, a.l.e wrote:
<br>
<blockquote type="cite">hi greg,
<br>
<blockquote type="cite">A while ago I was trying to find a way
to load CSV files with Scripter,
<br>
but this doesn't seem possible either.
<br>
</blockquote>
whaaaat? :-)
<br>
<br>
just use python to load a csv in a list... then you can loop
through it as you want.
<br>
should be almost trivial to do... i guess that by googling
"python csv" you should be able to find everything you need to
get started (and finished :-)
<br>
<br>
</blockquote>
and so I did.
<br>
I'll post on the wiki when I get a chance, for others reference.
<br>
One interesting thing probably relates to a discuss vlada and I
were having on #scribus about the infamous No Style -- if you
insertText, then setStyle, the first line does not get the style
you set. If you look in Story Editor, it's labeled as No Style.
<br>
The solution was to setStyle, then insertText, in which case the
first line is still No Style, but what's actually there is the
correct one.
<br>
<br>
</blockquote>
<br>
for those reading this archives and are not yet python programmers,
the relevant part is:<br>
<br>
<br>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<pre>import csv</pre>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<pre>csvfiledata = scribus.fileDialog('CSV file', 'CSV files(*.csv)')
with open(csvfiledata, 'rb') as csvfile:
census = csv.reader(csvfile)
for row in census:
scribus.insertText('\t'.join(row) + '\n', -1, textbox)
which lets you choose a .csv file and inserts the text as tab separated rows into the currently selected text frame.
of course you can do what you want with the "columns" and insert the fields in "row" in different frames, and ignore some of them.
thanks greg for sharing!
a.l.e
</pre>
</body>
</html>