Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple %VAR_ keynames to run script using different CSVs #204

Open
chsdramaboosters opened this issue Aug 10, 2022 · 4 comments
Open

Multiple %VAR_ keynames to run script using different CSVs #204

chsdramaboosters opened this issue Aug 10, 2022 · 4 comments

Comments

@chsdramaboosters
Copy link

chsdramaboosters commented Aug 10, 2022

Hi,
I'm building a theater playbill which is comprised of several sections ideal for scribus generator. However, each set of lists is somewhat unique, and would be well suited to a different CSV file and different ScribusGenerator run. Examples of sections include:

  • Cast list (role, actor)
  • Crew list (role, crewmember)
  • Headshots (first, last, image)
  • Bios (first, last, class, role, bio)
    Then, running throughout the playbill are advertising graphics, which too can be scribus-generator inserted based on a CSV with filenames.

Because of the linearity of ScribusGenerator, I've resorted to using Scribus levels to order the sections, then created a massive CSV with many headers and records ordered of by section. It works, but it's clumsy to manage several different sections within a single CSV file, as well as manage the levels in Scribus.

CSV looks something like this:
CastRole, CastActor, CrewRole, CrewMember, First, Last, HS-image, Class,Role, Bio
[cast list section]
Role1,Actor1,,,,,,,,
RoleN,ActorN,,,,,,,
[crew section]
,,Crew1,CrewM1,,,,,
,,CrewN,CrewMN,,,,,
[headshots section]
,,,,First1,Last1,HS-image1,,,
,,,,FirstN,LastN,HS-imageN,,,
[Who's Who section]
,,,,First1,Last1,,Class1, Role1, Bio1
,,,,FirstN,LastN,,ClassN, RoleN, BioN

Another method could be to expand the %VAR_ keyword to several. E.g., %VAR1_, %VAR2_, %VAR3_, etc, and tie %SG1_NEXT_RECORD% to %VAR1_ fields, and down the line.
I could then very likely ignore levels while running scribus-generator multiple times, pairing VAR1_ markings with csv1, VAR2 with csv2, etc. I'd have smaller, more managable csv files that themselves are easier to automate based on other data sources, and one master process to create the playbill section by section based on VAR-designator.

Is this possible? If so, how would I go about modifying the python scripts and CLI to support?

@berteh
Copy link
Owner

berteh commented Aug 16, 2022

Hello @chsdramaboosters,

I'm not sure I understand the whole story of your needs & wishes.

From what I gathered you want to generated a single document (pdf) that contains various sections, and most of these sections are either list-like or table-like sections with repeating attributes.

If that's the case, for the sake of flexibility and ease of maintenance I think I would use a separate scribus (SLA) file for each section, containing just the title for that section and the template for a list or table layout with some %SG_NEXT-RECORD% as needed per your layout: cast.sla, crew.sla, heads.sla, bios.sla and adds.sla
and maybe some related more "static" content, lets call them title.sla and last.sla for this example.

Similarly I'd have maybe 3 data (CSV or JSON) files with the relevant attributes: cast.csv, crew.csv, adds.csv

I would then create a single batch file to generate all the needed sections into separate files, so that it's easy to update/correct one part without damaging or having to redo the rest:

cd ~/currentMovie/playbill
python3 ScribusGeneratorCLI.py -n partCast -m cast.sla
python3 ScribusGeneratorCLI.py -n partCrew -m crew.sla
python3 ScribusGeneratorCLI.py -n partHeads1 -m -c cast.csv heads.sla
python3 ScribusGeneratorCLI.py -n partHeads2 -m -c crew.csv heads.sla
python3 ScribusGeneratorCLI.py -n partBios1 -m -c cast.csv bios.sla
python3 ScribusGeneratorCLI.py -n partBios2 -m -c crew.csv bios.sla
python3 ScribusGeneratorCLI.py -n "partAdds-%VAR_COUNT%" adds.sla

then merge them in your preferred order using either scribus (graphically but manually file > import) or the script at https://github.com/aoloe/scribus-script-repository/tree/master/sla-import

scribus -g -py sla-import.py empty.sla last.sla --page 1 --output tmp.sla --before
scribus -g -py sla-import.py tmp.sla partAdds-6.sla --page 1--before
scribus -g -py sla-import.py tmp.sla partBios2.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla partAdds-5.sla --page 1--before
scribus -g -py sla-import.py tmp.sla partBios1.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla partAdds-4.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla partHeads2.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla partAdds-3.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla partHeads1.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla partAdds-2.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla partCrew.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla partAdds-1.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla partCast.sla --page 1 --before
scribus -g -py sla-import.py tmp.sla title.sla --page 1 --before

Check it out and fine tune in Scribus, then export to pdf from within Scribus... or export directly from command line if you're happy with your workflow, using https://github.com/aoloe/scribus-script-repository/tree/master/sla-to-pdf

But that's just my 2 cents and if you have any reasons you don't like this approach please kindly explain where it doesn't work so I can try to better understand it.

@chsdramaboosters
Copy link
Author

Thank you, Berteh. The section by section approach is how I began. It is manageable, and the script to pull all sections back together is very helpful. The one piece Not addressed is that ad images are present across sections. I have 28 ad spaces mixed across all sections and am using %var_ for file paths and names. So even if broken into sections I’d need to keep the var_ ad(s) in the cast section separate from the var_ cast list with levels, which is just a mini version of what I’m already doing.
Whether breaking into sections or managing with levels, there are ways to make it work today. It’s a great tool and I thank you for it! The multi-var method proposed would, I think, alleviate some of the linearity challenges by enabling orthogonal instances of what you’ve already created within the same file, by a naming different var selector names. Easy for me to say, not being the designer or coder. So please take FWIW, and either way, I appreciate the generator and what it has enabled me to do already.

@berteh
Copy link
Owner

berteh commented Aug 17, 2022

Or you could maybe handle the adds with an 'hybrid' design that displays both a headshot and an add on top of each other (the order does not matter).

Then only one of these 2 variables (set) is given values in the data entry, thus showing as a single add in the headshots section (for example).

The SG script discards all unused variables by default, so the empty frames (headshot text and Pictures) are cleaned away.

Such an approach seems much more flexible to me than multi levels variables... for which I don't see many uses aside from yours. It works especially great with the ability of scribus to manage text flow around objects.

If you can share an example pdf (and opt sla + csv) i'd be happy to give it a try.

I mainly want to avoid making the SG script too complex: exceptions and double loops introduce many chances to break things in the far away future when another improvement requires some code refactoring. On the other hand I'm very open+interested in new features with many usage possibilities.

@chsdramaboosters
Copy link
Author

Sure. Have at it. Thanks! Final pdf too large so I split in half after generating.

Curious.csv
CuriousDraft2a.pdf
CuriousDraft2b.pdf
Playbill-Template-Curious.sla.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants