Score:2

LO Writer: Easiest way to put line of words into table as rows (list)

br flag

Let's say we have a series of words separated by commas in a LibreOffice Writer odt document:

"water, air, fire, sky, cloud, rain, snow, ice, wind, sun, moon, star, mountain..."

What is the easiest method to list them in a LO Writer table separated by rows?

Trying to convert them to table (TableConvertText to tableSeparate text at "Other" → selecting , - the result is that the words are separated by columns (where the commas where), but not by rows.

words separated by columns

How to separate them by rows so that they appear as a list?


I am going to do that a lot, that's why I am looking for the "easiest way". I do have a solution but I don't find it easy enough. I am posting it below as an example:

As things are, the "convert to table" option only has options applicable to an existing list with each word on a separate line.

To create the correct lines I have used the addon/extension called "Alternative searching" to replace the spaces between words with Paragraph (ending): \p.

Then, the method TableConvertText to tableSeparate text at Paragraph works.

Score:5
ca flag

This solution does what terdon's solution essentially does (which I prefer), but I'm adding it here since it can be done from within LibreOffice Writer, without using a terminal.

  1. Select the comma-separated list you want to convert to a single-column table.

  2. Press Ctrl+H (keyboard alternative for EditFind and Replace...).

  3. In the Find and Replace dialog that opens check Current selection only and Regular expressions and add:

    Find: ,

    Replace: \n

    Find and replace dialog

  4. Click Replace All.

  5. You should now have your selection as rows of text.

  6. Finally, to convert the rows to a single-column table: TableConvertText to Table... → set Separate Text at to ParagraphOK.


An alternative way is to use LibreOffice Calc to transpose the table (convert columns to rows and rows to columns), since Writer doesn't currently have that option:

  1. Convert the list of the comma-separated words to a table as you described in your question.

  2. Copy the table from Writer and paste it to Calc.

  3. Select the pasted row in Calc and press Ctrl+X to cut it.

  4. right-click on a cell and select Paste SpecialTranspose.

  5. Finally, copy the column with the words from Calc and paste it to Writer.

ar flag
The key here is the check marking the "Regular expression" box.
Score:3
cn flag

Just convert the commas to newlines and then copy paste them into your libreooffice document:

$ echo "water, air, fire, sky, cloud, rain, snow, ice, wind, sun, moon, star, mountain, river, lake, sea, fountain, wood, iron, gold, silver, lead" |
    sed 's/, */\n/g'

water
air
fire
sky
cloud
rain
snow
ice
wind
sun
moon
star
mountain
river
lake
sea
fountain
wood
iron
gold
silver
lead

You can also redirect to a file if te data are too large to copy and then open the file in libreoffice. Since they are now in rows, it should be trivial to convert to a table with one word per row.

br flag
I am going to do that a lot, that's why I am looking for the "easiest way". I do have a solution but I don't find it easy enough. I will post it into that question so that you could see what I mean.
BeastOfCaerbannog avatar
ca flag
To convert the rows to a single-column table: *Table* > *Convert* > *Text to Table...* > set *Separate Text at* to *Paragraph* > *OK*
BeastOfCaerbannog avatar
ca flag
@cipricus This is actually the easiest way. Unfortunately, LibreOffice Writer doesn't have an option to transpose tables, so the alternative is to use Calc to do that, which is more hassle than what terdon suggested.
br flag
As I see it, the only step lacking within LOW is to transpose the line of words into separate lines (separated by paragraph ending). I don't know how to do that with the "Find and Replace" tool but I can do it with an addon (Alt.Find and Replace) that has more options, so I can replace the coma with "Paragraph (ending)": `\p`
terdon avatar
cn flag
@cipricus isn't it easier to just pre-process the data in an external tool as I suggest instead of fiddling about with plugins and GUI stuff?
ar flag
Are the words already in a LibreOffice Writer (or MS Doc) file? If so, it may be more work to convert them to ASCII text, use `sed` and then move the words back to LibreOffice.
br flag
The addon is installed already, so it's internal to the LOW. I have to ask you to give me more details. For me CLI is more difficult, not easier. I will have to save in a file the necessary command until I learn it by heart :) and then to paste it in terminal along the list of words, than paste the list from terminal to the LO document. It is not easier, but it's very good to know (and learn).
terdon avatar
cn flag
Ah, OK. Then @cipricus, please clarify that you are already in a LOW document and have the words there. I assumed you had them in a text file. It is quite easy to write a little script that will automate this for you but we need to know the details. Then you could save the LOW as text, run the script on the file, open in LOW again and you have your table.
br flag
Maybe an easy way to use your command would be to create a shortcut containing a command with `xclip`!
terdon avatar
cn flag
I don't really know, I'm a command line geek and I find the GUI much harder, sorry :/
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.