[scribus] Scripter examples

JLuc jluc at no-log.org
Wed Dec 12 09:36:53 UTC 2012


Le 12/12/2012 09:46, a.l.e a écrit :
> On 12/11/12 8:15 PM, Gregory Pittman wrote:
>> On 12/11/2012 03:33 AM, a.l.e wrote:
>>> hi greg,
>>>> A while ago I was trying to find a way to load CSV files with Scripter,
>>>> but this doesn't seem possible either.
>>> whaaaat? :-)
>>>
>>> just use python to load a csv in a list... then you can loop through it as you want.
>>> 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 :-)
>>>
>> and so I did.
>> I'll post on the wiki when I get a chance, for others reference.
>> 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.
>> 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.
>>
>
> for those reading this archives and are not yet python programmers, the relevant part is:
>
>
> import csv
>
> 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!

Yes, thanks ale for explaining too, and thanks greg for sharing  :-)

If i understand well, this is with the traditionnal scripter,
and not operating with the NEW future scribus 1.5 scripter.

(So i changed the title of this thread).

JLuc




More information about the scribus mailing list