My count if function won't work for the letter "C". I checked for spaces with len function and I am super confused. Thanks for the help.
#of Accident Type
A 28
B 19
C =COUNTIF(A2:A101, "*C*")
D 17
E 9
F 9
Accidents
A
B
D
A
A
F
C
A
C
B
E
B
A
C
F
D
B
C
D
A
A
C
B
E
B
C
E
A
B
A
A
A
B
C
C
D
F
D
B
B
A
F
C
B
A
C
B
E
E
D
A
B
C
E
A
A
F
C
B
D
D
D
B
D
C
A
F
A
A
B
D
E
A
E
D
B
C
A
F
A
C
D
D
A
A
B
A
F
D
C
A
C
B
F
D
A
E
A
C
D
Seems to work fine, but I did not put the asterisks. Each cell (copied form the data example you gave) only has the character : no spaces...
Probably it does not work, because the C is written in Cyrillic. To make sure, whether this is the case, write C in English additionally and try to change the font to something Fancy - e.g. Algerian. Then the two C will be obviously different:
=COUNTIF(A2:A101,"*C*" )
For some reason its working now... I changed the font and messed around with it.
Thanks again for the help!!!!
Related
i need help in resolving a time consuming job
Input example
part number
where used
a
d
a
l
b
e
c
f
d
g
d
m
g
h
f
i
h
j
l
k
Result tree i need:
a
d
g
h
j
a
l
k
i am using pivot tabe to get this, but i cant arrive at that, kindly provide your guidance to make it
how does this script works and why the variable b get 50 as its value and not 1
a = 1
b = 50
b, b = a, b
print(b)
actual result: 50
b, b = a, b is actually a tuple assignment, and it works from left to right.
b, b = a, b evaluates to (b, b) = (1, 50) which in turn is executed as
b = 1
b = 50
I want to split a row of data into multiple columns like
a.dat
A B C D E F G H I J K L M N O P Q R S T U
into
b.dat
A B C D E F G
H I J K L M N
O P Q R S T U
I have tried using the pr function
pr -ts" " --columns 7 --across a.dat > b.dat
But it doesn't work, b.dat is the same as a.dat
I like fold for these thingies:
$ fold -w 14 file
A B C D E F G
H I J K L M N
O P Q R S T U
With -w you set the width you desire to have.
Although xargs is more useful if you want to split based on number of fields instead of characters:
$ xargs -n 7 < file
A B C D E F G
H I J K L M N
O P Q R S T U
Regarding your attempt in pr: I don't really know why it is not working, although from some examples I see it doesn't look like the tool for such job.
I want to replace all B after '='.
echo A, B = A B B A B B B | sed 's/=\(.*\)B\(.*\)/=\1C\2/g'
The expected result should be
A, B = A C C A C C C
But I got this result:
A, B = A B B A B B C
Only the last matched pattern be replaced. How to resolve it?
Use this sed:
sed ':loop; s/\(=.*\)B\(.*\)/\1C\2/; t loop'
Test:
$ echo A, B = A B B A B B B | sed ':loop; s/\(=.*\)B\(.*\)/\1C\2/; t loop'
A, B = A C C A C C C
Same kind of idea as #sat but starting from beginning of string
sed -e ':cycle' -e 's/\(.*=.*\)B/\1C/;t cycle'
posix compliant so should works on any sed
Say I have the following kinds of files:
file1.txt:
a a c
b b c
c c c
d d c
e e c
a a c
b b c
c c c
d d c
e e c
file2.txt:
—————
—————
—————
How do I get the contents from file2.txt so that I end up with file1.txt that says:
a a c
b b c
c c c
—————
—————
—————
d d c
e e c
a a c
b b c
c c c
d d c
e e c
...without just adding the contents after the 3rd line (first line with c c c).
Using GNU sed (The command needs to be spread across multiple lines):
sed '0,/c c c/ {
/c c c/r file2.txt
}' file1.txt
a a c
b b c
c c c
—————
—————
—————
d d c
e e c
a a c
b b c
c c c
d d c
e e c
awk 'NR==FNR{buf = buf $0 RS;next} {print} /c c c/ && !done{ printf "%s", buf; done=1 }' file2.txt file1.txt