Sponsored Content
Top Forums Shell Programming and Scripting convert data into matrix- awk Post 302602344 by quincyjones on Monday 27th of February 2012 05:31:09 AM
Old 02-27-2012
convert data into matrix- awk

is it possible to count the number of keys based on state and cell and output it as a simple matrix.

Ex: cell1-state1 has 2 keys
cell3-state1 has 4 keys.

Note: Insert 0 if no data available.

input

Code:
key    states    cell
key1    state1    cell1
key1    state2    cell1
key1    state3    cell1
key1    state4    cell1
key1    state5    cell1
key1    state6    cell1
key1    state7    cell1
key1    state8    cell1
key1    state9    cell1
key1    state10    cell1
key1    state11    cell1
key1    state12    cell1
key1    state13    cell1
key1    state14    cell1
key1    state15    cell1
key2    state1    cell1
key2    state2    cell1
key2    state3    cell1
key2    state4    cell1
key2    state5    cell1
key2    state6    cell1
key2    state7    cell1
key2    state8    cell1
key2    state9    cell1
key2    state10    cell1
key2    state11    cell1
key2    state12    cell1
key2    state13    cell1
key2    state14    cell1
key2    state15    cell1
key1    state1    cell2
key1    state2    cell2
key1    state3    cell2
key1    state4    cell2
key1    state5    cell2
key1    state6    cell2
key1    state7    cell2
key1    state8    cell2
key1    state9    cell2
key1    state10    cell2
key1    state11    cell2
key1    state12    cell2
key1    state13    cell2
key1    state14    cell2
key1    state15    cell2
key1    state1    cell3
key1    state14    cell3
key2    state1    cell3
key3    state1    cell3
key4    state1    cell3

output
Code:
cell    state1    state2    state3    state4    state5    state6    state7    state8    state9    state9    state10    state11    state12    state13    state14    state15
cell1    2    2    2    2    2    2    2    2    2    2    2    2    2    2    2
cell2    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
cell3    4    0    0    0    0    0    0    0    0    0    0    1    0    1    0

 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

By using AWK can I convert matrice shaped data to a row ?

Hello, I have output in the matrice form , for example: 1 2 3 4 a b c d jim joe sue tom how can I convert this line-column data into a row as follows 1 2 3 4 a b c d jim joe sue tom thank you (14 Replies)
Discussion started by: rpf
14 Replies

2. Shell Programming and Scripting

two-column data to matrix in AWK

Howdy, I need to convert an association data matrix, currently in a two-column format, into a matrix with numbers indicating the number of associations. I've been looking around for AWK code in the list, but could not find anything. Here's an example of what I want to perform: original... (10 Replies)
Discussion started by: sramirez
10 Replies

3. Ubuntu

How to convert full data matrix to linearised left data matrix?

Hi all, Is there a way to convert full data matrix to linearised left data matrix? e.g full data matrix Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7 Bh1 0 0.241058 0.236129 0.244397 0.237479 0.240767 0.245245 Bh2 0.241058 0 0.240594 0.241931 0.241975 ... (8 Replies)
Discussion started by: evoll
8 Replies

4. UNIX for Dummies Questions & Answers

Convert nxm Matrix into columns of data

Dear Unixers, I'm having some difficulty in converting an n x m data matrix into a dataset of 3 columns and nxm rows. As an example I want to convert this dataset 2 3 4 5 2 0.0 0.0 0.1 0.1 6 -0.3 2.0 0.0 0.3 7 -0.6 -1.1 0.5 0.3 9 -0.9 -4.1 -0.7 0.5 ... (2 Replies)
Discussion started by: tintin72
2 Replies

5. Shell Programming and Scripting

awk to convert table-by-row to matrix table

Hello, I need some help to reformat this table-by-row to matrix? infile: site1 A:o,p,q,r,s,t site1 C:y,u site1 T:v,w site1 -:x,z site2 A:p,r,t,v,w,z site2 C:u,y site2 G:q,s site2 -:o,x site3 A:o,q,s,t,u,z site3 C:y site3 T:v,w,x site3 -:p,routfile: SITE o p q r s t v u w x y... (7 Replies)
Discussion started by: yifangt
7 Replies

6. Shell Programming and Scripting

How order a data matrix using awk?

is it possible to order the following row clusters from ascending to descending. thanx in advance input 1 2 4 0 1 2 4 0 3 3 3 3 1 5 1 0 1 5 1 0 6 0 0 0 5 1 1 1... (4 Replies)
Discussion started by: quincyjones
4 Replies

7. Shell Programming and Scripting

Convert data into tabular matrix

Hi There, I want to convert the following data into tabular matrix, based on column 4th and 5th, and output the column 10th value chr1 2804449 2804450 NACpG_1 window1 + chr1 2804443 2804475 1 chr1 2804450 2804451 NACpG_1 window2 + chr1 2804443 ... (3 Replies)
Discussion started by: ChiragNepal
3 Replies

8. Shell Programming and Scripting

How to convert 2 columns into matrix -awk?

How can i convert two columns in to o and 1 matrix. thnks Input a c1 b c2 c c1 d c3 e c4 output c1 c2 c3 c4 a 1 0 0 0 b 0 1 0 0 c 1 0 0 0 d 0 0 ... (5 Replies)
Discussion started by: quincyjones
5 Replies
DBIPROF(1)						User Contributed Perl Documentation						DBIPROF(1)

NAME
dbiprof - command-line client for DBI::ProfileData SYNOPSIS
See a report of the ten queries with the longest total runtime in the profile dump file prof1.out: dbiprof prof1.out See the top 10 most frequently run queries in the profile file dbi.prof (the default): dbiprof --sort count See the same report with 15 entries: dbiprof --sort count --number 15 DESCRIPTION
This tool is a command-line client for the DBI::ProfileData. It allows you to analyze the profile data file produced by DBI::ProfileDumper and produce various useful reports. OPTIONS
This program accepts the following options: --number N Produce this many items in the report. Defaults to 10. If set to "all" then all results are shown. --sort field Sort results by the given field. Sorting by multiple fields isn't currently supported (patches welcome). The available sort fields are: total Sorts by total time run time across all runs. This is the default sort. longest Sorts by the longest single run. count Sorts by total number of runs. first Sorts by the time taken in the first run. shortest Sorts by the shortest single run. key1 Sorts by the value of the first element in the Path, which should be numeric. You can also sort by "key2" and "key3". --reverse Reverses the selected sort. For example, to see a report of the shortest overall time: dbiprof --sort total --reverse --match keyN=value Consider only items where the specified key matches the given value. Keys are numbered from 1. For example, let's say you used a DBI::Profile Path of: [ DBIprofile_Statement, DBIprofile_Methodname ] And called dbiprof as in: dbiprof --match key2=execute Your report would only show execute queries, leaving out prepares, fetches, etc. If the value given starts and ends with slashes ("/") then it will be treated as a regular expression. For example, to only include SELECT queries where key1 is the statement: dbiprof --match key1=/^SELECT/ By default the match expression is matched case-insensitively, but this can be changed with the --case-sensitive option. --exclude keyN=value Remove items for where the specified key matches the given value. For example, to exclude all prepare entries where key2 is the method name: dbiprof --exclude key2=prepare Like "--match", If the value given starts and ends with slashes ("/") then it will be treated as a regular expression. For example, to exclude UPDATE queries where key1 is the statement: dbiprof --match key1=/^UPDATE/ By default the exclude expression is matched case-insensitively, but this can be changed with the --case-sensitive option. --case-sensitive Using this option causes --match and --exclude to work case-sensitively. Defaults to off. --delete Sets the "DeleteFiles" option to DBI::ProfileData which causes the files to be deleted after reading. See DBI::ProfileData for more details. --dumpnodes Print the list of nodes in the form of a perl data structure. Use the "-sort" option if you want the list sorted. --version Print the dbiprof version number and exit. AUTHOR
Sam Tregar <sam@tregar.com> COPYRIGHT AND LICENSE
Copyright (C) 2002 Sam Tregar This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. SEE ALSO
DBI::ProfileDumper, DBI::Profile, DBI. perl v5.16.2 2013-08-25 DBIPROF(1)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy