berteh / ScribusGenerator

Create beautiful documents with data. Open source pdf (and Scribus) template and mail-merge alternative.
http://berteh.github.io/ScribusGenerator/
MIT License
243 stars 37 forks source link

file name offset #190

Closed MartinZaske closed 2 years ago

MartinZaske commented 2 years ago

This issue is less urgent than the other one I just wrote.

In my personal ScribusGenerator fork I have had an "offset" for years with its own input-box in the GUI, which allows me to run several batches of "file generations" from different CSV data files and have them all saved in one huge folder, for easier printing by some other scripts of mine.

So instead of generating each time the same files-names like 1, 2, 3 or better 001, 002, 003 (see my previous issue) I used to have the option to enter an offset of 500 (for example) and then generate for example 501, 502, 503.

My offset is not string-added, it is mathematically added to the index; so it works fine even if I generate many files: 500 + 1 = 501; 500 + 233 = 733 etc. So when I create another batch, I just have to look in my file-browser and use an appropriate-size offset. And this allows me to have all my output together and still see which file is part of which batch. Very useful to me.

Again my question: Is this feature interesting to other users?

And if yes, should I attempt to work on the code (might take me several days and I do not want to create conflicts with other work) or would the core team consider doing it properly?

Of course I can show the few lines of how I did it back in a very old version of ScribusGenerator, it is not too complex. But things have matured so much here, that I fear my skills are no match for the current version.

Please let me know what you think,

Martin

berteh commented 2 years ago

Do you need the numbers of all generated files to be a strict sequence of numbers with no gaps?

If not I would propose to use the features that already exists to use some variables in the output file name, for instance, adding a variable "prefix" or "series" to your data and using the following string as output file name: "myfile_%VARseries%" I personal like to use uppercase letters in my series (AA < AZ < ZZ), but you can use numbers all the same.

I'd rather avoid adding new options unless they have big added value, but am happy to do it if it's really needed. hope this helps, B.

berteh commented 2 years ago

after reading your post more carefuly I gather you may not want to have that "offset" in the CSV data. Then you can just put it manually in the output file name, either in the GUI or CLI, increasing the last series number you used by one.

eg, if last file was myfileBJ 078.sla, then the output file name used for next generation might be myfileBK

MartinZaske commented 2 years ago

Dear berteh,

thank you for kindly looking at my request #190.

You are right, that I do not need a very specific list of file names in our batches. It would just be great for my existing scripts, if things would not change dramatically. Otherwise I need to adapt my script for pagination and for batch-printing.

Your ideas gave me more of my own ideas:

I just tested to put nothing but a prefix in the "file name box" like "22_" and hoped that since I did not use any regular %VAR_something% at all, that maybe the new Scribus Generator would kindly add the good ole index numbers. But instead it created all 100 output files at that same file name, writing one over the other. Was just a test. Did not work as hoped.

I have total control over our data files, since I generate them myself. So I have to consider whether I prefer hacking the Phython code again to have my offset feature, or whether I just quickly hack each CSV file with a numbering to my liking and use that for file name purposes. I see several options for that.

I will let you know here. For now, since you clearly wrote "I'd rather avoid adding new options unless they have big added value" I will withdraw my request #190. Like I had written, this one is less urgent.

berteh commented 2 years ago

the overwriting of output files instead of increment is a bug that will be fixed very soon, sorry.

berteh commented 2 years ago

variable names should now be substituted as expected, along with a dedicated variable that gives the counter (%VAR_COUNT%) in output file name. kindly test and feedback if this works for you in python3 branch (scribus 1.5.6+)

doc: https://github.com/berteh/ScribusGenerator/blob/python3/README.md#dynamic-output-file-location (improvement to the documentation are welcome too, if you have a way to make it more clear in short, thanks.)