Sponsored Content
Full Discussion: List to matrix
Top Forums UNIX for Dummies Questions & Answers List to matrix Post 302924585 by senhia83 on Monday 10th of November 2014 10:23:54 PM
Old 11-10-2014
Hi Ravinder,

The input that you provided seems to have duplicate 1st and 2nd col combinations.

Code:
 
cat matrix_test
1,a,1a
1,b,1b
1,c,1c
2,a,2a
2,b,2b
3,a,3a
4,d,1a
4,d,1b
5,e,1a
5,e,1b


I did some testing with the following input and the output is incorrect, would you please look into it?
I have highlighted the incorrect row.

Code:
 
1,a,1a
1,b,1b
1,c,1c
2,a,2a
2,b,2b
3,a,3a
4,d,1a
5,a,1b


The output that I`m getting

Code:
 
a,b,c,d
1,1a,1b,1c,-
2,2a,2b,-,-
3,3a,-,-,-
4,1a,-,-,-
5,1b,-,-,-

The correct output

Code:
 
a,b,c,d
1,1a,1b,1c,-
2,2a,2b,-,-
3,3a,-,-,-
4,-,-,-,1a
5,1b,-,-,-


Last edited by senhia83; 11-11-2014 at 12:41 AM..
 

9 More Discussions You Might Find Interesting

1. Programming

Converting distance list to distance matrix in R

Hi power user, I have this type of data (distance list): file1 A B 10 B C 20 C D 50I want output like this # A B C D A 0 10 30 80 B 10 0 20 70 C 30 20 0 50 D 80 70 50 0 Which is a distance matrix I have tried... (0 Replies)
Discussion started by: anjas
0 Replies

2. Shell Programming and Scripting

diagonal matrix to square matrix

Hello, all! I am struggling with a short script to read a diagonal matrix for later retrieval. 1.000 0.234 0.435 0.123 0.012 0.102 0.325 0.412 0.087 0.098 1.000 0.111 0.412 0.115 0.058 0.091 0.190 0.045 0.058 1.000 0.205 0.542 0.335 0.054 0.117 0.203 0.125 1.000 0.587 0.159 0.357... (11 Replies)
Discussion started by: yifangt
11 Replies

3. Shell Programming and Scripting

Matrix construction

Hi experts How to construct a rectangular matrix for a text file with 6012 rows and 2221 columns. Thank You (1 Reply)
Discussion started by: riyabio
1 Replies

4. Shell Programming and Scripting

Matrix construction

Hi I have to construct a rectangular matrix with 6012 rows and 2221 columns. Here the rows and columns were given by alphanumeric ids in a file named row.txt and column.txt respectively. with this row nd column ids I have to construct a matrix ie 6012*2221 and compare the column ids with... (0 Replies)
Discussion started by: riyabio
0 Replies

5. Shell Programming and Scripting

Matrix

Hi All I would like to merge multiple files with the same row and column size into a matrix format In a folder I have multiple files in the following format vi 12.txt a 1 b 5 c 7 d 0 vi 45.txt a 3 b 6 c 9 d 2 vi 9.txt a 4 (7 Replies)
Discussion started by: Lucky Ali
7 Replies

6. 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

7. Shell Programming and Scripting

awk? adjacency matrix to adjacency list / correlation matrix to list

Hi everyone I am very new at awk but think that that might be the best strategy for this. I have a matrix very similar to a correlation matrix and in practical terms I need to convert it into a list containing the values from the matrix (one value per line) with the first field of the line (row... (5 Replies)
Discussion started by: stonemonkey
5 Replies

8. Shell Programming and Scripting

Randomize a matrix

--please have a look at my third post in this thread! there I explained it more clearly-- Hey guys. I posted a complex problem few days back. No reply! :| Here is simplified question: I have a matrix with 0/1: * col1 col2 col3 row1 1 0 1 row2 0 0 ... (5 Replies)
Discussion started by: @man
5 Replies

9. Shell Programming and Scripting

Weighted adjacency list to adjacency matrix

dear awk gurus, i would need a fast (therefore) awk solution for the reformation of an uncomplete weighted adjacency list to a complete sorted adjacency matrix. example (FS=OFS=,): a,d,0.33 a,b,0.25 b,c,0.11 should give: ,a,b,c,d a,1,0.25,0,0.33 b,0.25,1,0.11,0... (4 Replies)
Discussion started by: dietmar13
4 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 04:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy