[Solved] Convert vertical word list to horizontal

Discuss the word processor

[Solved] Convert vertical word list to horizontal

Postby jimhebert722 » Mon May 11, 2020 1:46 am

Hi: :D
In Apache Text Writer Doc I have several words in alphabetical order in a vertical column (not a table column). Some of the words are 2 or 3 line spacing apart. All are aligned left. How do I get them in a horizontal line in the same order and separated by a coma followed by a space after each word?
Last edited by Hagar Delest on Tue May 12, 2020 7:25 am, edited 1 time in total.
Reason: tagged solved
jimhebert722
 
Posts: 7
Joined: Mon May 11, 2020 1:34 am

Re: Convert vertical word list to horizontal

Postby FJCC » Mon May 11, 2020 2:34 am

If you words are arranged as I think they are, you can use the following. If it does not work, please upload a sample document.

1. Eliminate the empty paragraphs by
A. Selecting the menu Edit -> Find & Replace
B. In the Search For box enter ^$
C. Leave the Replace With box empty,
D. Under More Options select Regular Expressions
E. Click Replace All
2. Replace the Paragraph ends with a comma and a space.
A. In the Search For box enter $
B. In the Replace With box enter a comma followed by a space.
C. Click Replace All

If you have a very long list, removing all of the paragraph marks will cause problems because the paragraph will be longer than the maximum supported lenth (~64,000 characters?).
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7748
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Convert vertical word list to horizontal

Postby jimhebert722 » Mon May 11, 2020 2:42 am

I got to Step E & a pop-up said "Search Key not found".
OpenOffice 3.1 on Windows Vista
jimhebert722
 
Posts: 7
Joined: Mon May 11, 2020 1:34 am

Re: Convert vertical word list to horizontal

Postby robleyd » Mon May 11, 2020 2:50 am

Use Ctrl-F10 or View | Non-printing Characters to show end of line markers. Do you see a backwards P ¶ or a left pointing arrow ↩ at the end of your empty lines?
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 3458
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Convert vertical word list to horizontal

Postby jimhebert722 » Mon May 11, 2020 3:19 am

2 of the empty lines don't show the backward P. All the rest of the empty lines have a backward P and there is a backward P at the end of each word on the vertical list.
OpenOffice 3.1 on Windows Vista
jimhebert722
 
Posts: 7
Joined: Mon May 11, 2020 1:34 am

Re: Convert vertical word list to horizontal

Postby JeJe » Mon May 11, 2020 7:42 am

What do you mean by "several"? If several is half a dozen then I'd put the cursor in front of each word, press backspace enough then type the comma and space manually. Its not elegant but it won't take long.

Otherwise Alt search is an extension which allows you to replace some surplus lines/line feeds with commas and spaces a little easier

https://extensions.openoffice.org/en/node/525/releases
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1145
Joined: Wed Mar 09, 2016 2:40 pm

Re: Convert vertical word list to horizontal

Postby Bill » Mon May 11, 2020 9:05 am

jimhebert722 wrote:2 of the empty lines don't show the backward P. All the rest of the empty lines have a backward P and there is a backward P at the end of each word on the vertical list.

Check the instructions posted by FJCC. They worked perfectly for me. Step E finds and deletes empty paragraphs. An empty line with a backward P is an empty paragraph.
AOO 4.1.7, LO 6.3.6.2 and LO 6.4.3.2 on Kubuntu 20.04
Bill
Volunteer
 
Posts: 7862
Joined: Sat Nov 24, 2007 6:48 am

Re: Convert vertical word list to horizontal

Postby robleyd » Mon May 11, 2020 9:19 am

2 of the empty lines don't show the backward P

Probably the lines are filled with spaces or some other white space; spaces will show as dots when you are displaying non-printing characters and tabs look like right pointing arrows.
Cheers
David
Apache OpenOffice 420m2(Build:9821) - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 3458
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Convert vertical word list to horizontal

Postby JeJe » Mon May 11, 2020 10:04 am

Look at the paragraph format and make sure the line spacing is set to single and the spacing above and below the paragraph is 0.
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1145
Joined: Wed Mar 09, 2016 2:40 pm

Re: Convert vertical word list to horizontal

Postby John_Ha » Mon May 11, 2020 10:36 am

Use a regular expression to delete the end of paragraph or new line characters. Edit > Find and Replace. More Options. Tick regular expressions. Click Help or read the tutorial on regular expressions.

Or use the Alt Find and Replace add-on

Or

1. Copy into a spreadsheet
2. Use TRANSPOSE to transpose the array. Or use ROTATING TABLES to transpose the selection. Search Help
3. Copy back.

Or upload a small file with the text so that it can be analysed. Press POSTREPLY and click the Upload attachment tab below where you type (128 kB max); or use a file share site, Dropbox or Google Drive for a larger file.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7794
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Convert vertical word list to horizontal

Postby JeJe » Mon May 11, 2020 11:39 am

If there's no formatting, the words are just plain text, then this macro should convert the selection

Code: Select all   Expand viewCollapse view
Sub ParasToCommaDelineated
vc = thiscomponent.currentcontroller.viewcursor
sts =split( vc.string,chr(13) & chr(10))
vc.string=join(sts,", ")
End Sub
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1145
Joined: Wed Mar 09, 2016 2:40 pm

Re: Convert vertical word list to horizontal

Postby JeJe » Mon May 11, 2020 1:39 pm

Slightly more complicated macro converts selected lines to comma delineated but preserves formatting.

Code: Select all   Expand viewCollapse view
sub ParasToCommaDelineated
odoc = thiscomponent
sel =odoc.currentcontroller.selection.getbyindex(0)
l=odoc.text.createtextcursorbyrange(  sel.getstart)
r=odoc.text.createtextcursorbyrange(  sel.getend)
do
res=r.gotoStartOfParagraph(false)
if not res then exit do
If oDoc.Text.compareRegionEnds(l, r) <=0 Then Exit Do
r.goleft(1,true)
r.string = ", "
loop
End Sub
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1145
Joined: Wed Mar 09, 2016 2:40 pm

Re: Convert vertical word list to horizontal

Postby jimhebert722 » Mon May 11, 2020 2:30 pm

I am not well versed in how to use Macros, sorry, JeJe. I did the manual insertion of comas and spaces. I repeated your original instructions and when I got to Step E I received the same pop-up and no inverted P's appeared anywhere. To Robleyd, the paragraphs are set to single line and all 0's.
OpenOffice 3.1 on Windows Vista
jimhebert722
 
Posts: 7
Joined: Mon May 11, 2020 1:34 am

Re: Convert vertical word list to horizontal

Postby John_Ha » Mon May 11, 2020 4:24 pm

Please upload a small file showing your data.

Press POSTREPLY and click the Upload attachment tab below where you type (128 kB max); or use a file share site, Dropbox or Google Drive for a larger file.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7794
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Convert vertical word list to horizontal

Postby jimhebert722 » Mon May 11, 2020 4:48 pm

File requested by John_Ha
Attachments
P Table.odt
(9.69 KiB) Downloaded 35 times
jimhebert722
 
Posts: 7
Joined: Mon May 11, 2020 1:34 am

Re: Convert vertical word list to horizontal

Postby JeJe » Mon May 11, 2020 5:00 pm

FJCC's instructions work perfectly well on that file. Are you ticking the Regular expressions tickbox?

Abrot, Achy-a, Acon, Adel, Adlu, Aesc, Aeth, Agar, Agar-em, Agath-a, Aids, Alco, Alco-s, Alf, All-c, All-s, Aln, Aloe, Alum, Alum-met, Alumn, Ambr, Am-c, Aml-n, Am-m, Ammc, Amyg-am, Amyg-p, Anac, Anag, Anemps, Ang, Ango, Anh, Anil, Anis, Ant-c, Anth, Antho, Antipyrin, Ant-o, Ant-s, Ant-t, Ap-g, Aphis, Apis, Aq-pet, Aral, Aran, Arbu, Arec, Arge-p, Arg-m, Arg-n, Arn, Ars, Ars-br, Ars-h, Ars-i, Ars-s-f, Ars-s-r, Ars-t-s, Art-v, Arum-d, Arum-dru, Arum-i, Arum-m, Arund, Asaf, Asar, Asc-c, Astra-e, Astra-me, Atha-o, Atista, Aur, Aven,


Edit:

^$ to enter in the search box in those instructions is just those two letters, no space before. Can't think how it can not be working...
Create a new document with all your words in and follow those instructions carefully...
Openoffice 4.1.6
Windows 8
JeJe
Volunteer
 
Posts: 1145
Joined: Wed Mar 09, 2016 2:40 pm

Re: Convert vertical word list to horizontal

Postby Lupp » Mon May 11, 2020 6:32 pm

Just for completeness:
A solution by user code based on the REGEX() function only available in LibreOffice V 6.2 or higher.
It seems to be really efficient.
With long lists the old limit of 65535 for the number of characters in a single paragraph may also come in sight. In LibO this limit is no longer in force. (Neither for paragraphs in text documents nor for cells in spreadsheets.)

You may want to play with the attachment.
On Windows 10: LibreOffice 7.0 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2913
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Convert vertical word list to horizontal

Postby John_Ha » Mon May 11, 2020 6:33 pm

The spreadsheet ROTATE trick works fine.

Having seen the data the additional step is to sort the column to separate the empty lines. Paste Special > unformatted back into Writer. Do a regular expression search for /t (the tabs) and replace them all by ,sp (comma space).
Abrot, Abrot, Achy-a, Acon, Adel, Adlu, Aesc, Aeth, Agar, Agar-em, Agath-a, Aids, Alco, Alco-s, Alf, All-c, All-s, Aln, Aloe, Alum, Alum-met, Alumn, Am-c, Am-m, Ambr, Aml-n, Ammc, Amyg-am, Amyg-p, Anac, Anag, Anemps, Ang, Ango, Anh, Anil, Anis, Ant-c, Ant-o, Ant-s, Ant-t, Anth, Antho, Antipyrin, Ap-g, Aphis, Apis, Aq-pet, Aral, Aran, Arbu, Arec, Arg-m, Arg-n, Arge-p, Arn, Ars, Ars-br, Ars-h, Ars-i, Ars-s-f, Ars-s-r, Ars-t-s, Art-v, Arum-d, Arum-dru, Arum-i, Arum-m, Arund, Asaf, Asar, Asc-c, Astra-e, Astra-me, Atha-o, Atista, Aur, Aven
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7794
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Convert vertical word list to horizontal

Postby jimhebert722 » Mon May 11, 2020 7:18 pm

I tried copy and pasted the vertical word list on a new doc and retried. I first clicked the Inverted P on the tool bar to verify that I had no more empty lines and checked OK. I then followed the instructions. In the "Search for" block I clicked on Shift 6 to get the ^ and then Shift s to get S. The Regular expressions block was already ticked. I clicked "Replace All". A pop-up titled Open Office 4.1.7 says "Search Key not found." I am wondering if maybe I don't have an extension that I never downloaded. It has to be something that my downloaded Open Office is lacking. I even tried re-installing it and it did the same. Something is lacking in my version since it works on yours. On the license agreement it says I must have Java for Open Office to work properly. I have 64bit Firefox browser and Java says that java will not work on that browser. So I don't know if that is the problem? So I didn't download Java.
I installed Open Off in C:\ProgramFiles, ...Maybe I should have installed it in C:\ProgramFiles(x86)

To John_Ha : I tried Special paste: unformatted....it didn't work. I tried an ordinary search for /t and it didn't find anything.
OpenOffice 3.1 on Windows Vista
jimhebert722
 
Posts: 7
Joined: Mon May 11, 2020 1:34 am

Re: Convert vertical word list to horizontal

Postby John_Ha » Mon May 11, 2020 8:19 pm

Read the posts - they tell you what to do. Do not miss any steps.

You do not seem to understand regular expressions so
Click Help or read the tutorial on regular expressions.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 7794
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Convert vertical word list to horizontal

Postby Bill » Mon May 11, 2020 8:48 pm

jimhebert722 wrote:...then Shift s to get S.

That's why it doesn't work. You're inserting an upper case "S" but you should be inserting a dollar sign "$". That's Shift+4 on a US keyboard.
AOO 4.1.7, LO 6.3.6.2 and LO 6.4.3.2 on Kubuntu 20.04
Bill
Volunteer
 
Posts: 7862
Joined: Sat Nov 24, 2007 6:48 am

Re: Convert vertical word list to horizontal

Postby jimhebert722 » Mon May 11, 2020 9:06 pm

I can't believe..haha...I kept thinking that maybe I am not entering something correctly which is why I decided to tell you exacty each key I was hitting. Just by looking at it quickly I thought it was an S. The $ on the key pad is a lot clearer looking . Maybe I need glasses....Thanks for the time and I will send a donation to the forum. Thanks Bill. Also JeJe, etc.
OpenOffice 3.1 on Windows Vista
jimhebert722
 
Posts: 7
Joined: Mon May 11, 2020 1:34 am


Return to Writer

Who is online

Users browsing this forum: JeJe and 20 guests