Transforming a calc sheet into a Writer document

I use a google form to collect data. It ends up in a Google sheets that I copy and paste in a Calc sheet.
The sheet has a header row. Like this:

| field 1 | field 2 | field 3 | field 4 |

| reply 1 | reply 1 | reply 1 | reply 1 |

| reply 2 | reply 2 | reply 2 | reply 2 |

etc.

I want to create a writer document with this structure

field 1
reply 1
field 2
reply 1
field 3
reply 1
field 4
reply 1

field 1
reply 2
field 2
reply 2
field 3
reply 2
field 4
reply 2

etc.

How do I go about it?

1 Like

Report.odt (14.7 KB)
Database report made from csv file as data source. The same report could be made from a spreadsheet.

and

No clue concerning the why.
The workflow looks funny, and using the final result must be a pain.

Just for fun I created a sketch for a solution with an intention in my mind to show the amount of deviations needed to do it the way the questioner described as what he “wants”.

How tom use the result must be a secret of the ages.
See attachment:
disask116242veryStrangeRearrangement.ods (39.5 KB)

Reports for different sections separated by page breaks. I forgot the page breaks in my sample.

Where did the questioner mention page breaks?
But possibly he only wanted printed paper, and the “Writer document” was an offspring of an XY-issue?
If it is about printing in the given way from a Calc sheet, PrintRange settings are the appropriate means:

  • Add the columns one by one to the print ranges.
  • Set print sequence top to bottom, then right.
  • Suppress output of empty pages.

See print preview for the attached document.
disask116242simplyPrinting.ods (63.7 KB)

Howto:

  1. File>New>Database…
    1.1. Connect to existing database, type: Spreadsheet
    1.2. Specify the location of your spreadsheet.
    1.3. Save the database document and have a look at the pseudo-tables. They represent the used cell ranges of each sheet.
  2. Right-click the right table icon, choose “Report Wizard…”
    2.1. Follow the instructions and choose a block layout.
  3. Save the database document.
    3.1. right-click report → Edit…
    3.2. Adjust the positions of the elements.

Finally, save the report and its embedding database.

Notice that the database does not contain any data. The spreadsheet data are treated as a pseudo-database. You can not edit the data in Base.

for a one shot, would be easier to stay in csv, then text with a (compact :slight_smile: ) perl-ish nested loop like :

perl -e '$s=" ?\\| ?"; @h=split $s,<>; while(@r=split $s,<>){ foreach $h (@h) { print "$h\n",shift @r, "\n"}}'   yourdata.csv 

you can adjust in the sandbox : Online Perl Compiler (Interpreter)

1 Like