My data contain 0 which I want to remove with -9, but not those data point which are like 220 or 120. How to do it? For example data are like:
M1 M2 M3 M4
120 0 125 0
0 123 123 0
123 0 0 123
to
M1 M2 M3 M4
120 -9 125 -9
-9 123 123 -9
123 -9 -9 123
You would search for " 0 " and replace with " -9 "
Related
I have this data set ( txt).
For example:
input:
0 275,276,45,278
1 442,22,455,0,456,457,458
75 62,263,264,265,266,267
80 0,516,294,517,518,519
I would like as output
output:
0 275
0 276
0 45
...
1 442
1 22
...
80 0
I use unix terminal. Let me know if you have some ideas. Thanks
Ignoring the last part you mentioned "80 454", I found a solution to print as required.
Suppose all these values are stored in a file names "stack.txt", the following bash code will be useful.
#!/bin/bash
while read i;do
f=$(awk -F" " '{print $1}' <<< $i)
line=$(cut -d" " -f2 <<<$i)
for m in $(echo $line | sed "s/,/ /g"); do
echo $f" "$m
done
echo "..."
done<stack.txt
Output will be
0 275
0 276
0 277
0 278
0 279
0 280
0 281
0 282
0 283
...
1 442
1 22
1 455
1 0
1 456
1 457
1 458
...
75 62
75 263
75 264
75 265
75 266
75 267
...
80 0
80 516
80 294
80 517
80 518
80 519
...
Using a perl one-liner:
perl -lane 'print "$F[0] $_" for split /,/, $F[1]' input.txt
{m,n,g}awk 'gsub(",",RS $!_ FS)^_'
0 275
0 276
0 277
0 278
0 279
0 280
0 281
0 282
0 283
1 442
1 22
1 455
1 0
1 456
1 457
1 458
75 62
75 263
75 264
75 265
75 266
75 267
80 0
80 516
80 294
80 517
80 518
80 519
I have some bladefs volume and I just checked /proc/self/mountstats where I see statistics per operations:
...
opts: rw,vers=3,rsize=131072,wsize=131072,namlen=255,acregmin=1800,acregmax=1800,acdirmin=1800,acdirmax=1800,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=10.0.2.100,mountvers=3,mountport=903,mountproto=tcp,local_lock=all
age: 18129
caps: caps=0x3fc7,wtmult=512,dtsize=32768,bsize=0,namlen=255
sec: flavor=1,pseudoflavor=1
events: 18840 116049 23 5808 22138 21048 146984 13896 287 2181 0 7560 31380 0 9565 5106 0 6471 0 0 13896 0 0 0 0 0 0
bytes: 339548407 48622919 0 0 311167118 48622919 76846 13896
RPC iostats version: 1.0 p/v: 100003/3 (nfs)
xprt: tcp 875 1 7 0 0 85765 85764 1 206637 0 37 1776 35298
per-op statistics
NULL: 0 0 0 0 0 0 0 0
GETATTR: 18840 18840 0 2336164 2110080 92 8027 8817
SETATTR: 0 0 0 0 0 0 0 0
LOOKUP: 21391 21392 0 3877744 4562876 118 103403 105518
ACCESS: 20183 20188 0 2584304 2421960 72 10122 10850
READLINK: 0 0 0 0 0 0 0 0
READ: 3425 3425 0 465848 311606600 340 97323 97924
WRITE: 2422 2422 0 48975488 387520 763 200645 201522
CREATE: 2616 2616 0 447392 701088 21 870 1088
MKDIR: 858 858 0 188760 229944 8 573 705
SYMLINK: 0 0 0 0 0 0 0 0
MKNOD: 0 0 0 0 0 0 0 0
REMOVE: 47 47 0 6440 6768 0 8 76
RMDIR: 23 23 0 4876 3312 0 3 5
RENAME: 23 23 0 7176 5980 0 5 6
LINK: 0 0 0 0 0 0 0 0
READDIR: 160 160 0 23040 4987464 0 16139 16142
READDIRPLUS: 15703 15703 0 2324044 8493604 43 1041634 1041907
FSSTAT: 1 1 0 124 168 0 0 0
FSINFO: 2 2 0 248 328 0 0 0
PATHCONF: 1 1 0 124 140 0 0 0
COMMIT: 68 68 0 9248 10336 2 272 275...
about my bladefs. I am interested in READ operation statistics. As I know the last column (97924) means:
execute: How long ops of this type take to execute (from
rpc_init_task to rpc_exit_task) (microsecond)
How to interpret this? Is it the average time of each read operation regardless of the block size? I have very strong suspicion that I have problems with NFS: am I right? The value of 0.1 sec looks bad for me, but I am not sure how exactly to interpret this time: average, some sum...?
After reading the kernel source, the statistics are printed from net/sunrpc/stats.c rpc_clnt_show_stats() and the 8th column of per-op statistics statistics seems to printed from _print_rpc_iostats, it's printing struct rpc_iostats member om_execute. (The newest kernel has 9 columns with errors on the last column.)
That member looks to be only referenced/actually changed in rpc_count_iostats_metrics with:
execute = ktime_sub(now, task->tk_start);
op_metrics->om_execute = ktime_add(op_metrics->om_execute, execute);
Assuming ktime_add does what it says, the value of om_execute only increases. So the 8th column of mountstats would be the sum of the time of operations of this type.
I have 2 data sets. First, a master table that displays and sums all of the information from the reference tables. The master table looks like this.
BayNum NumCompleted
102
103
104
105
The reference table is a running timeline with indicator variables for whether or not something was completed at various time intervals.
BayNum 1030 1100 1130 1200 1230
102 1 0 1 0 0
102 0 0 1 0 1
102 1 0 0 1 0
102 0 0 0 0 1
103 0 1 1 1 0
103 1 0 0 0 1
103 1 0 1 1 1
104 1 0 0 0 1
104 0 0 1 0 1
104 1 0 0 1 0
104 1 0 0 0 1
104 1 0 0 0 1
105 1 0 1 0 0
105 0 1 1 1 0
105 0 0 0 0 1
I would like the NumCompleted column in the master table to sum all all of the records that have the same bay number.
I think that there is some sort of sumproduct way to go about this but I don't understand arrays very well so I am having trouble visualizing how this works in my head.
I tried this formula
=SUMPRODUCT(INDEX(TPH!H2:NC166,MATCH('Post Observations'!$G$2,TPH!$F$2:$F$166,0)))
But this returns a reference error I think because Index can only work through a column instead of a full array or something. Would I have to instead do something with Index Small so that it runs through the full list of things? I've done something like that before but I don't know if that would apply here.
Per the example above, I would expect my master table to look like this.
BayNum NumCompleted
102 7
103 9
104 10
105 6
You can use SUMPRODUCT to multiply each cell in the range, by whether the "BayNum" matches (1 if it does or 0 if not), then sum all the results:
=SUMPRODUCT(($B$2:$F$8)*($A$2:$A$8=$H2))
I am working on a machine learning project and am using Excel to handle the dataset. I am new to both Excel and VBA.
So I am using this dataset, and I just copy pasted the whole thing into an excel spreadsheet. I did text to columns. Here's a snapshot of some of the data:
Snapshot of data
I want to reformat the data in the spreadsheet so that all of the data goes into a single row, then starts a new row after the "name" keyword.
For example, I want this:
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18
19 20 21 22 23 name
to become:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 name (all on one line)
without having to do it manually line by line.
I used the below VBA code to format the data how I want it:
Sub separateByName()
Dim lRow As Long
Dim lCol As Long
Dim lCol2 As Long
k = 1
lRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lRow
lCol = Cells(i, Columns.Count).End(xlToLeft).Column
For j = 1 To lCol
lCol2 = Sheets("Sheet2").Cells(k, Columns.Count).End(xlToLeft).Column
Sheets("Sheet2").Cells(k, lCol2 + 1).Value = Cells(i, j).Value
If Cells(i, j).Value = "name" Then k = k + 1
Next j
Next i
End Sub
However, when I run I'm getting problems in that the result seems randomly patterned.
This:
1 0 63 1 -9 -9 -9
-9 1 145 1 233 -9 50 20
1 -9 1 2 2 3 81 0
0 0 0 0 1 10.5 6 13
150 60 190 90 145 85 0 0
2.3 3 -9 172 0 -9 -9 -9
-9 -9 -9 6 -9 -9 -9 2
16 81 0 1 1 1 -9 1
-9 1 -9 1 1 1 1 1
1 1 -9 -9 name
2 0 67 1 -9 -9 -9
-9 4 160 1 286 -9 40 40
0 -9 1 2 3 5 81 0
1 0 0 0 1 9.5 6 13
108 64 160 90 160 90 1 0
1.5 2 -9 185 3 -9 -9 -9
-9 -9 -9 3 -9 -9 -9 2
5 81 2 1 2 2 -9 2
-9 1 -9 1 1 1 1 1
1 1 -9 -9 name
Became this:
1 0 63 1 -9 -9 -9 1 0 63 1 -9 -9 -9 -9 1 145 1 233 -9 50 20 1 -9 1 2 2 3 81 0 0 0 0 0 1 10.5 6 13 150 60 190 90 145 85 0 0 2.3 3 -9 172 0 -9 -9 -9 -9 -9 -9 6 -9 -9 -9 2 16 81 0 1 1 1 -9 1 -9 1 -9 1 1 1 1 1 1 1 -9 -9 name
-9 1 145 1 233 -9 50 20 2 0 67 1 -9 -9 -9 -9 4 160 1 286 -9 40 40 0 -9 1 2 3 5 81 0 1 0 0 0 1 9.5 6 13 108 64 160 90 160 90 1 0 1.5 2 -9 185 3 -9 -9 -9 -9 -9 -9 3 -9 -9 -9 2 5 81 2 1 2 2 -9 2 -9 1 -9 1 1 1 1 1 1 1 -9 -9 name
The "name" is correctly at the end, but the actual data is messed up.
Could anyone help me to fix this code for my dataset?
Thanks!
I also tested your code with data and i got it to work just fine, just make sure on sheet 1 you have the data and you have empty sheet 2, then use the macro while sheet 1 is open. then your data is in sheet 2.
I would like to know the CPU and memory usage of a process and all of its children processes in Linux.
it would be better to have solution using ps command.but other solutions are also welcome.
Please help
Thanks
Shuja
Here's a simple script to do what you want. Your options will vary depending upon the version of 'ps' you are using. The result is comma delimitated so you can pass it into a spread sheet.
ps -vl | awk '{print $1 ", " $11 ", " $12 ", " $15}' | sed -n '/^424/ p'
where you change the 424 into whatever parent PID you want. Of course, if there's something else with the same digits as your PID, you'll have to be a little careful.
Someone ~
$ ps -vl
PID STAT TIME SL RE PAGEIN VSZ RSS LIM TSIZ %CPU %MEM COMMAND UID PPID F CPU PRI NI WCHAN ADDR TTY
432 S+ 0:00.01 0 0 0 2499948 1696 - 0 0.0 0.0 -bash 501 431 4006 0 31 0 - 0 ttys001
618 S 0:00.06 0 0 0 2465132 1656 - 0 0.0 0.0 -bash 501 617 4006 0 31 0 - 0 ttys002
424 S+ 0:00.01 0 0 0 2482540 1620 - 0 0.0 0.0 -bash 501 423 4006 0 31 0 - 0 ttys000
629 S+ 0:00.02 0 0 0 2463084 1612 - 0 0.0 0.0 -bash 501 628 4006 0 31 0 - 0 ttys003
Someone ~
$ ps -vl | awk '{print $1 ", " $11 ", " $12 ", " $15}' | sed -n '/^424/ p'
424, 0.0, 0.0, 423
Someone ~
$