What is the "next cell character" when coping and pasting from a table?

3

1

You know when you copy a row from a table and paste it into another one it is in the correct place. So what is the character that is between cell values when this operation is performed.

Eg. I have this text: Phone (P), Email (E), Home (H) and if I replace all the , with \n and paste the text in a tabular formant in Pages/Word/Excel, it is interpreted as a column.

To replace the string with new line I used:

> pbpaste | tr -s ', ' '\n' | pbcopy 

I tried \t, and \n\n but they're still pasted as a row.

Next I tried copying it in a row and printing on the terminal using (gcat because I'm on macOS):

> pbpaste | gcat -A 
a^Ib^Ic⏎  

Reading the docs it says:

display TAB characters as ^I

But replacing , with \t doesn't do it. Does anyone know what character this is and how I can replace a comma with it to paste a row?

user14492

Posted 2018-06-26T21:48:25.617

Reputation: 131

It’s the tab character – Tony Stewart Sunnyskyguy EE75 – 2018-06-26T21:55:37.753

If \t doesn't do it, maybe ^t will? – cybernetic.nomad – 2018-06-26T21:56:45.287

1tr is the wrong command for this task. Try pbpaste | sed 's/, / /g' | pbcopy. Note that you can't simply copy the command from this comment. Control-v followed by the tab key allows you to enter a tab character on the Terminal command line. When typing this command in Terminal, type s/, /control-v tab/g. – creidhne – 2018-06-27T00:29:44.453

@creidhne funny thing is when I asked the best way to replace a substring with another string before people said to not use sed and use tr.... sed is quite confusing for me and for a simple replace without any regex it's not anymore helpful. – user14492 – 2018-06-28T13:11:09.440

1But did the sed command solve the problem? The problem with tr is that it translates characters, not strings. sed uses so-called "basic regex" but sed -E uses modern "extended regex". The sed command replaces every , (comma followed by a blank) with a tab character. Would an answer help? – creidhne – 2018-06-28T13:49:03.410

"for a simple replace without any regex ".. || reminds me.. in Japanese technologies... The toughest/advanced one to handle, is the simple one. (simplest solution/zero-thinking-on user site) || If the method works.. then it ok.. If not, we always have the option to create our own program and/or using assembly/c++ . || I hope you don't get me wrong.. I'm just interested to know if it works.. + I don't have a mac to try it out. [ : – p._phidot_ – 2018-10-11T19:33:28.500

You are using command line utility (as I understand by seeing >) and sed and tr, why you tagged this post "microsoft-excel microsoft-word worksheet-function"? I mean are you doing these changes in .doc(x), .xls(x) files? You surely can't as they are proprietary format and can't be edited from command line as above. And where does worksheet function fit here? – VSRawat – 2019-02-08T17:56:24.337

@VSRawat who are you, the tag police? What is the purpose of that comment? One can argue you’re spamming and not adding anything of value to the question. – user14492 – 2019-02-08T18:02:09.713

All I am saying that if those tags are not relevant for the content of this post, you should remove that and put only such tags as are required for this post. If you think I am spamming, no issue, please flag my comment so that some moderator reads and judges it. – VSRawat – 2019-02-08T18:08:43.507

Answers

0

In Excel, you can define which character is used as a delimiter by using the "Text to Column" option.(I discovered this by going crazy when I was pasting values and it was getting split somehow.)

If you go to the Text To Column option in the Data tab, it first asks if it is Delimited or Fixed Width. Select delimited, then hit next.

On the next screen, you may select Tab, Semicolon, Comma, Space or Other (with a field to say which is the other character). Set it there and finish.

If you had, for example, 1,2 and pasted normally, it would fill only one cell. However if you do this process and select Comma, when you paste again it will split on the Comma.

It is not exactly what the question asked for, because the asker wanted to know what to replace the comma and in various programs, but this way you do not need to replace it at all, instead making Excel understand you want to split on the comma.

Moacir

Posted 2018-06-26T21:48:25.617

Reputation: 254