I will be getting hundreds of spreadsheets (.csv) with columns like this:
SA,C,FN,MN,LN,G,A,ID # header row
sa1,c1,fn1,mn1,ln1,m,33,123
sa1,c1,fn2,mn2,ln2,f,44,124 # group 1
sa1,c1,fn3,mn3,ln3,m,55,125
sa2,c2,fn4,mn4,ln4,f,22,126 # group 2
sa3,c3,fn5,mn5,ln5,m,25,172 # group 3
sa3,c3,fn6,mn6,ln6,f,65,188
sa3,c3,fn7,mn7,ln7,m,67,192
sa3,c3,fn8,mn8,ln8,f,42,195
sa3,c3,fn9,mn9,ln9,m,25,204
sa3,c3,fn10,mn10,ln10,m,69,511
sa4,c4,fn11,mn11,ln11,f,72,515 # group 4
…
Every time I see saN,cN change, I would like to start a new page with this info in a block that appears only on that page.
Each fnN,mnN,etc needs to appear in a new block with that data.
The result in this example would create 6 pages (yes, 6)…
Page 1(1)
header block (sa1, c1) # header
client block (fn1, …)
client block (fn2, …)
Page 2(1)
header block (sa2, c2) # header
client block (fn3, …)
Page 3(1)
header block (sa3, c3) # header
client block (fn4, …)
client block (fn5, …)
Page 4(2)
client block (fn6, …)
client block (fn7, …)
client block (fn8, …)
Page 5(3)
client block (fn9, …)
Page 6(1)
header block (sa4, c4) # header
client block (fn10, …)
The goal is to have a header and N clients, without repeating that header:
Group #1 fills its page 1 with the header, and 2 clients’ info.
Group #2 only fills the top 2/3 of its page 1 with the header, and 1 client’s info.
Group #3 only fills its page 1 with the header, and 2 clients’ info;
then, its page 2 with no header, and 3 clients’ info;
then, its page 3 with no header, and 1 clients’ info.
Group #4 only fills the top 2/3 of its page 1 with the header, and 1 client’s info.
I’ve been able to create a flat odt (.fodt) “template” file and cut it into chunks which are then processed by a Python script which somewhat works. The long term challenge is the the template will likely change based on region. The “chunking” of the .fodt is not my idea of fun; it would be near impossible to train regional folk to do this.
Is there a way to create such a template with conditional blocks?
A major restriction is not having to change the incoming sheets.
The biggest issue I face is outputting only the number of blocks needed.
Ideas? Or, am I stuck breaking a template into chunks and using Python’s f-string to fill in the chunks?