Help with Changing Comma-Separated Text to a List [in a Specific Way]

Joined
Mar 3, 2010
Messages
94
Reaction score
0
Hi!

I use Google Docs at work. What I'm trying to do is modify something from a comma separated list to a bulleted, PLAIN TEXT list. The best way I can describe it is this:

Value A, Value B, Value C

to

- Value A
- Value B
- Value C
Notice that I need to replace the commas with both line breaks AND en dashes. There seems to be no simple instant formatting tool online that I've come across.​
Any help?

Thank you! 8^)​
 
Joined
Jun 1, 2021
Messages
139
Reaction score
21
I'm using old text editing software called TextWrangler which can do search and replace like that. I think they've long since updated it to BBEdit which I presume is even better.

Can you export your Google Doc to plain text? If yes, I'll take a shot at it if you want.

Perl is also very good at such things, but learning that to do this would be overkill.
 
Joined
Jan 25, 2017
Messages
1,267
Reaction score
100
I have written a small Python script to accomplish what you require, I guess I could add that to an automator script, if that would help.
 
Joined
Mar 3, 2010
Messages
94
Reaction score
0
Thanks very much to both of you! Sorry I hadn't replied sooner. I've been exploring different combos & trying to simplify the process before saying further about this.

All right, to backtrack a little & hopefully make this easier ...

Is there a way to simply add dashes (en dashes) at the start of each new line without relying on a bulleted list--effective replacing line breaks with a line break and a minus sign?

THAT would be mega-helpful!

Thanks either way!!
 
Joined
Feb 14, 2021
Messages
986
Reaction score
131
That’s what TextWrangler/BBEdit can do using Find/Replace. You might need some rudimentary knowledge of Grep, but whatever terms you might need are easily available in the built-in Help. Once you have set up the Find/Replace fields, one click will perform the task in mere seconds, the only caveat being that there be no extraneous commas elsewhere, which shouldn’t be the case with a comma-delimited file.

The Find field will be “\, ” (less the quote marks)

The Replace field will be “\r– ” (note also the spaces at the end, per your example)

“Grep” and “Wrap around” should be checked.

Note also that an EN-dash is different from a hyphen. To generate an EN-dash in BBEdit, or in most other apps, the keystroke is [option-hyphen] (less the brackets).
 
Joined
Sep 29, 2021
Messages
25
Reaction score
1
Have you tried the create Table facility? (a) Convert text to table (choose 1 column), (b) convert table back to text, this gives you a list) (c) convert to a bulleted list (you can also choose the bullet you want). Sorry, I don't know whether this is the answer you are looking for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top