Remove white space at the end of text in Excel - excel

I have a large number of data in excel, which have whitespace in end of text.
Example :
"Lorem ipsum "
or
"Lorem ipsum "
How can I remove the whitespace?
Result :
"Lorem ipsum"
UPDATE :
I look the answer and worked for normal whitespace, i did research and found my whitespace is a unicode character. So i use this method and worked.
=TRIM(SUBSTITUTE(Lorem ipsum ,CHAR(160),CHAR(32)))
Thanks.
Source : http://office.microsoft.com/en-001/help/remove-spaces-and-nonprinting-characters-from-text-HP010062743.aspx?CTT=5&origin=HP010062581

If the double quotes are part of the data you could use this:
=TRIM(LEFT(A2, LEN(A2)-1))&""""
Result:
If the double quotes were only for display purposes just use this:
=TRIM(A2)

In pretty much every programming languages removing the trailing spaces is done with the TRIM() function. So for your case in excel :
=TRIM("Lorem ipsum ")
=TRIM(" Lorem ipsum")
=TRIM(" Lorem ipsum ")
=TRIM("Lorem ipsum")
Will all output the same result (without any trailing spaces):
Lorem ipsum
For more information on the trim function : http://office.microsoft.com/en-001/excel-help/trim-function-HP010062581.aspx

Related

vim - Delete to the end from Searched word

I would like to remain the only the first pattern (The "Important#") in the text.
Input:
Im port ant1 RandomJunk
Imp ortan t4 Lorum ipsum
Imp ort ant5 dolor sit amet, conse
I mport ant3 Aliquam vel nibh diam
Impo rtant 1 dignissim vel nisi vitae
Imp orta nt9 dui ut posuere rhoncu
Output:
Im port ant1
Imp ortan t4
Imp ort ant5
I mport ant3
Impo rtant 1
Imp orta nt9
New to vim and don't really understand :%s or :s
Please help
Assuming that you have to delete everything after 12th character on each line
you can use vim's search and replace:
Overall command structure:
:s/searchThis/replaceWithThis
This is a command to do the job:
:%s/\(.\{12}\).*/\1
Explanation:
% - signals to apply search and replace on each line in a file
\(.\{12}\).* - search part
\(.\{12\}\).* is a regex, (, ), {, } escaped with \ so vim
engine will understand that those are special signs. Without escaping it looks like this: (.{12}).*.
(.{12}) - capturing group, match first any 12 characters
.* - any character. zero or more times *
\1 - replace part, it means keep only first captured group after matching.
In our case those will be first 12 character on the line.
More thorough explanation on search and replace in vim wiki
Use the Jeday powers (regex) of vim:
:%s/\d \zs.*//
Read more at --> :h \zs
:%norm 3whD
% ................ in the whole file
norm ............. in normal mode
3w ............... jump 3 words
h ................ move one char to the left
D ................ delete the rest of the line

Print all pairs of values in column of tsv file via bash

I want to write a small shell script to make a labeling task easier for myself. Alas, I'm still lacking the skills to do so.
I've got a news.tsv file which looks like this:
id foo bar text
1 a b lorem
2 c d ipsum
...
50 e f muspi
Where the actual entries in the text column are lengthy news articles. I want to print 2 of these texts at once, until all possible pairs in the column have been printed.
Searching for a solution, I found that awk might be the right tool for the task. I know how to print two specific entries in the text column, e.g,
awk -F '\t' 'NR==2 {print $4} NR==3 {print $4}' news.tsv
will print lorem and ipsum. For getting all pairs, I think I'll need a nested for-loop, but I fail at implementing it with awk.
My spaghetti-try looks like this:
awk -F '\t' '{for (i=0; i<50; i++){for (j=i+1; j<50; j++) if(i!=j){NR==i {print $4} NR==j {print $4}}}}' news.tsv
I'm open for other tools as well.
Is this what you want?
awk 'NR>1 {print $4; next; print $4}'
Here's an attempt based on your own script ... assuming that there are no embedded TABs, ever.
$ cat awkward
NR>1{
a[NR-1]=$4
}
END{
for(i=1;i<=50;i++){
for(j=1;j<=50;j++){
if(i!=j){
print a[i],a[j]
}
}
}
}
Invoked like so:
$ awk -f awkward test.tsv
Lorem ipsum
Lorem dolor
Lorem sit
Lorem amet,
Lorem consectetur
Lorem adipiscing
Lorem elit,
Lorem sed
Lorem do
Lorem eiusmod
.
.
[over 2000 lines stripped]
.
.
fugiat dolor
fugiat in
fugiat reprehenderit
fugiat in
fugiat voluptate
fugiat velit
fugiat esse
fugiat cillum
fugiat dolore
fugiat eu
If the total amount of the texts is not so huge, it will be efficient
store the whole texts in an array. Otherwise you need to read the input file
multiple times (the number of combination).
Then how about:
awk -F '\t' '
NR>1 {texts[++n]=$4}
END {
for (i=1; i<n; i++) {
for (j=i+1; j<=n; j++) {
print texts[i] " " texts[j]
}
}
}' news.tsv
Hope this helps.

How to wrap text around a path defined in svg (using css)?

My goal is to wrap some text around a shape defined with svg.
The shape is path looking like a rectangle with a 1/2 circular hole.
<svg width="100px" height="200px" viewBox="0 0 50 100">
<path id="halfcircleLeft" d="M 50 26 ... Z" style="fill: lightgray;"></path>
</svg>
In the html, I define the wrapping element with a <div>
<div class="svgLeftShape"></div>
and I set his css like this:
.svgLeftShape
{
shape-outside: url(#halfcircleLeft);
float: left;
width: 100px;
height: 200px;
}
Should work, isn't it?
Well, it is not working as expected!
It sounds like the text is wrapped around the rectangle defined through the css width and height. The shape reference to the svg element is ignored ...
What am I doing wrong?
In the following Fiddle, I have added a 'css' circle on the right just to make sure I was not missing the basics.
Warning :
First, you should know that the CSS Shapes Module Level 1 actualy
(april 2015) has the status of "Candidate Recommendation". As this
means it is a work in progress, it may change at any moment and
therefore shape-outside should not be used other than for
testing.
This property is actualy only supported by chrome and requires the -webkit- vendor prefix that you haven't included in your code.
Here is an example that you will only be able to view in chrome 37+ :
.shape {
-webkit-shape-outside: circle(100px);
shape-outside: circle(100px);
width: 200px;
height: 200px;
float: left;
}
<div class="shape"></div>
<p>It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body. It includes techniques such as applying herbal-infused
oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body. It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation,
deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body. It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific
points, mobilizing the joints, and warming the body.</p>
Using images for the shape-outside :
I am not aware wether you can use svg images or not. But you can use .png images and the shape will be generated according to the transparency of the image :
img{
-webkit-shape-outside: url(http://i.imgur.com/yZcQxF6.png);
shape-outside: url(http://i.imgur.com/yZcQxF6.png);
float: left;
width: 100px;
height: 200px;
}
<img src="http://i.imgur.com/yZcQxF6.png"/>
<p>It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body. It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body. It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body. It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body. It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body. It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body. It includes techniques such as applying herbal-infused oils to the body, manual tissue manipulation, deep tissue work, identifying & acting on specific points, mobilizing the joints, and warming the body.</p>
Note : If your image has several levels of transparency, you can control which level defines the outline of the shape with the shape-image-threshold propery.
EDIT: The use of svgs for the shape-outside property is discussed in the CSS shapes module level 2
These are experimental features and I would not recommend using them yet since they will only render properly in chrome.
.tri {
-webkit-shape-outside: polygon(0 0, 100% 100%, 0 100%);
float: left;
width: 40%;
height: 12ex;
background-color: lightgray;
-webkit-clip-path: polygon(0 0, 100% 100%, 0 100%);
}
.rect {
-webkit-shape-outside: inset(0 0, 100px 100px 100px 100px);
width: 100px;
height: 80px;
float: left;
background-color: tomato;
-webkit-clip-path: inset(0 0, 100px 100px 100px 100px);
}
.circ {
height: 100px;
width: 100px;
-webkit-shape-outside: circle(40%);
shape-outside: circle(40%);
transition: shape-outside 1s;
float: left;
background-color: tomato;
-webkit-clip-path: circle(40%);
}
.circ:hover {
-webkit-shape-outside: circle(50%);
shape-outside: circle(50%);
-webkit-clip-path: circle(50%);
}
<div class="main">
<div class="tri"></div>
<p>
This is really experimental and "CHROME ONLY", Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum
dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet
</p>
<div class="rect"></div>
<p>
This is really experimental and "CHROME ONLY", Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum
dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet
</p>
<div class="circ"></div>
<p>
HOVERING ?! hell yh :D HOVERING ?! hell yh :D HOVERING ?! hell yh :D HOVERING ?! hell yh :D HOVERING ?! hell yh :D HOVERING ?! hell yh :D HOVERING ?! hell yh :D HOVERING ?! hell yh :D HOVERING ?! hell yh :D HOVERING ?! hell yh :D HOVERING ?! hell yh :D
HOVERING ?! hell yh :D HOVERING ?! hell yh
</div>
All of this wil only work in chrome at time of writing unfortunately.
Now the syntax does say that images are allowed.
So this wil only
#image {
-webkit-shape-outside: url("http://i198.photobucket.com/albums/aa49/Nightlady070/Cliparts/Internet_Explorer_7_Logo_red_zps21ac8b59.png");
shape-outside: url("http://i198.photobucket.com/albums/aa49/Nightlady070/Cliparts/Internet_Explorer_7_Logo_red_zps21ac8b59.png");
-webkit-shape-image-threshold: 0.1;
shape-image-threshold: 0.1;
float: left;
}
<img id="image" src="http://i198.photobucket.com/albums/aa49/Nightlady070/Cliparts/Internet_Explorer_7_Logo_red_zps21ac8b59.png" />
<p>Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet,
Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Loremt, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet</p>
Now to SVG images SVG as shape draft
Seems there is no support for this element yet, since it only finds the outer most svg and not the shape elements.
#image {
-webkit-shape-outside: url("http://images3.wikia.nocookie.net/__cb20120330024139/logopedia/images/d/d7/Google_Chrome_logo_2011.svg");
shape-outside: url("http://images3.wikia.nocookie.net/__cb20120330024139/logopedia/images/d/d7/Google_Chrome_logo_2011.svg");
-webkit-shape-image-threshold: 0.1;
shape-image-threshold: 0.1;
float: left;
}
<img id="image" src="http://images3.wikia.nocookie.net/__cb20120330024139/logopedia/images/d/d7/Google_Chrome_logo_2011.svg" />
<p>Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet,
Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet,
Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet, Lorem ipsum dollar si amet</p>

how to insert contents to beginning and end of a visual block using vim scripting

I am new to vim scripting. Is it possible to do the following using vim scripting?
I have a visual block of text. By pressing function key (say F5) I need to insert some text to beginning and end of my visual block.
i.e. the following text is in visual block:
Lorem ipusm doret lorem ipsum. Lorem ipusm doret lorem ipsum. Lorem ipusm doret lorem ipsum. Lorem Lorem ipusm doret lorem ipsum.
Lorem ipusm doret lorem ipsum. Lorem ipusm doret lorem ipsum. Lorem ipusm doret lorem ipsum. Ipusm doret lorem ipsum.
On pressing F5 key, the text should be changed to:
"[[Lorem ipusm doret lorem ipsum. Lorem ipusm doret lorem ipsum. Lorem ipusm doret lorem ipsum. Lorem Lorem ipusm doret lorem ipsum.
Lorem ipusm doret lorem ipsum. Lorem ipusm doret lorem ipsum. Lorem ipusm doret lorem ipsum. Ipusm doret lorem ipsum.]]"
The text "[[ and ]]" needs to be placed on beginning and end of the visual block. Can anybody give me a solution for this.
How would you do this manually? Use `< to go to the beginning of the visual selection, i"[[ to insert the text, Esc to go back to normal mode, repeat at the other end.
In a mapping:
:vnoremap <F5> <Esc>g`<i"[[<Esc>g`>a]]"<Esc>
Check out the surround addon. It gives you the ability to take a visual selection or an area defined by a motion (e.g. a word, the text within a pair of parentheses, etc.) and quickly and conveniently surround it with a pair of characters.

What do the f and t commands do in Vim?

What do f and t commands do in vim and exactly how they work?
Your first stop with questions like these should be vim's internal help, :h f and :h t. However, in this case, those entries are a bit cryptic without an example. Suppose we had this line (^ = cursor position):
The quick brown fox jumps over the lazy dog.
^
These commands find characters on a line. So fb would place the cursor here:
The quick brown fox jumps over the lazy dog.
^
t is like f but places the cursor on the preceding character. So tb would give you:
The quick brown fox jumps over the lazy dog.
^
You can remember these commands as find and till. Also, you can prepend the commands with a number to move to the nth occurrence of that character. For example, 3fb would move to the third b to the right of the cursor. My example sentence only has one b though, so the cursor wouldn't move at all.
Just to add to Michael Kristofik's answer, no description of f or t is complete without also mentioning ;.
From this Vim cheat sheet:
; "Repeat latest f, t, F or T [count] times."
So, to continue the #MichaelKristofik's theme:
The quick brown fox jumps over the lazy dog.
^
type fo to go to the first 'o':
The quick brown fox jumps over the lazy dog.
^
and then ; to go to the next one:
The quick brown fox jumps over the lazy dog.
^
I find f and t very useful in combination with d and c. For example, ct: will let you replace everything from your cursor up to the next colon, but not delete the colon. You can remember it as "change to colon".
fx jumps to the next x on the line.
tx jumps to the character just before the next x on the line.
You can use Fx and Tx to reach the previous x.
You can use 2fx to jump to the second x on the line.
So, fFand tT are useful when you want to go quickly to the next set of parentheses (f() or delete everything from the cursor to, but excluding, the previous = (dT=) and so on…
See :h motion.txt. It will blow your mind.
Since LondonRob mentioned ;, I guess a description of the comma , command is in order. It is used very much in conjunction with these commands (when the search overshoots).
After performing a search with f, F, t or T, one could use , to repeat the search in the opposite direction.
Let's say we are at the start of this sentence, and we would like to change the elot to elit.
Lorem ipsum dolor sit amet consectetur adipiscing elot sed do eiusmod tempor.
^
I know I have to replace an o, so I perform an fo (find o) immediately. The cursor is stuck at some early o in the line! Hit ; to repeat the search in the same direction. Type type type... I should have just done it five times, but let's say I overshoot and type ; six times instead. I end up here:
Lorem ipsum dolor sit amet consectetur adipiscing elot sed do eiusmod tempor.
^
Lorem ipsum dolor sit amet consectetur adipiscing elot sed do eiusmod tempor.
^
Lorem ipsum dolor sit amet consectetur adipiscing elot sed do eiusmod tempor.
^
Lorem ipsum dolor sit amet consectetur adipiscing elot sed do eiusmod tempor.
^
Lorem ipsum dolor sit amet consectetur adipiscing elot sed do eiusmod tempor.
^
Lorem ipsum dolor sit amet consectetur adipiscing elot sed do eiusmod tempor.
^
Lorem ipsum dolor sit amet consectetur adipiscing elot sed do eiusmod tempor.
^
Now, one could just perform a , twice to repeat this search in the other direction. The cursor will reach the o in elot.
Lorem ipsum dolor sit amet, consectetur adipiscing elot, sed do eiusmod tempor.
^
Lorem ipsum dolor sit amet, consectetur adipiscing elot, sed do eiusmod tempor.
^
ri to finish the replacement.
As with most movement commands, , also take a count: [count],.
From the manual:
Repeat latest f, t, F or T in opposite direction [count] times.

Resources