Sponsored Content
Full Discussion: 3 Columns to Row question
Top Forums Shell Programming and Scripting 3 Columns to Row question Post 302262663 by joeyg on Friday 28th of November 2008 09:58:20 AM
Old 11-28-2008
Hammer & Screwdriver An interesting output, but not quite what you wanted

I thought I figured a quicker way, but the following (while doing something kind of cool) did not provide what you were looking for. However, I thought it would be a good entry to exist in the forum's repositor of Q&A.

Code:
> cat file79
a
b
c
d
e
f
g
h
i

> split -3 file79 f79s | paste f79saa f79sab f79sac
a       d       g
b       e       h
c       f       i

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Row to Columns

Hi, I have a file like this. 1,1,1,0,0,0 1,1,2,1,0,0 1,1,3,0,0,0 1,1,4,0,0,0 ........... ........... 1,1,24,0,0,0 1,1,25,0,0,0 1,1,26,1,0,0 1,1,27,0,0,0 1,2,1,0,0,0 1,2,2,0,0,0 1,2,3,0,0,0 1,2,4,0,0,0 1,2,5,1,0,0 1,2,6,1,0,0 (4 Replies)
Discussion started by: vskr72
4 Replies

2. Shell Programming and Scripting

how to change row into columns

hi, I have a input file like a,123,456,789,012,.......,b I need to change the output file into a,123,b a,456,b a,789,b a,012,b a,...,b like that.. how to achieve that through UNIX................. (5 Replies)
Discussion started by: aaha_naga
5 Replies

3. Shell Programming and Scripting

Row to Columns question

Hi, I have a question for Row to Columns by script. e.g. i have a file Start 1 2 3 4 End Start 1 2 3 3 4 4 End (6 Replies)
Discussion started by: bleach8578
6 Replies

4. Shell Programming and Scripting

Convert columns to single row

Hello all I have data like 1 2 3 4 5 I wish my output would be like 1,2,3,4,5 For this i have executed 'BEGIN {FS="\n"; ORS=","} {print $0}' test and got the output as 1,2,3,4,5, I do not want to have , at the end of 5. output should be like (5 Replies)
Discussion started by: vasuarjula
5 Replies

5. Shell Programming and Scripting

Print columns from each row

I have awk command to print column 8 awk '/select/ {print $8}' which will print column 8 But I need to print 3, 5 and 8 column in a row and each column should be de-limited by "\t" Hope anyone help me quickly. (2 Replies)
Discussion started by: elamurugu
2 Replies

6. Shell Programming and Scripting

help [[row and columns]]

i ask to do ,,program that convert the last row to be the first row ,,,and after that exchange the the columns ex,, 1 2 3 4 5 6 7 8 9 to be 7 8 9 4 5 6 1 2 3 and then to be 9 8 7 6 5 4 3 2 1 give mee the code .... (0 Replies)
Discussion started by: khaled1989kh
0 Replies

7. UNIX for Dummies Questions & Answers

help [[row and columns]]

i ask to do ,,program that convert the last row to be the first row ,,,and after that exchange the the columns ex,, 1 2 3 4 5 6 7 8 9 to be 7 8 9 4 5 6 1 2 3 and then to be 9 8 7 6 5 4 3 2 1 (0 Replies)
Discussion started by: khaled1989kh
0 Replies

8. UNIX for Dummies Questions & Answers

Select 2 columns and transpose row by row

Hi, I have a tab-delimited file as follows: 1 1 2 2 3 3 4 4 a a b b c c d d 5 5 6 6 7 7 8 8 e e f f g g h h 9 9 10 10 11 11 12 12 i i j j k k l l 13 13 14 14 15 15 16 16 m m n n o o p p The output I need is: 1 1 a a 5 5 e e 9 9 i i 13... (5 Replies)
Discussion started by: mvaishnav
5 Replies

9. Shell Programming and Scripting

Grep and print only certain columns from a row

Hi Friends, This is my input chr1 100 200 + gene_name "alpha"; protein_name "alpha"; level 2; tag "basic"; info "known"; chr1 245 290 + gene_name "alpha-1"; protein_name "alpha-2"; level 9; tag "basic"; info "uknown"; chr1 310 320 + gene_name "alpha"; protein_name "alpha-4"; level 2; info... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

10. Shell Programming and Scripting

Transpose columns to row

Gents Using the attached file and using this code. awk '{print substr($0,4,2)}' input.txt | sort -k1n | awk '{a++}END{for(i in a) print i,a}' | sort -k1 > output i got the this output. 00 739 01 807 02 840 03 735 04 782 05 850 06 754 07 295 08 388 09 670 10 669 11 762 (8 Replies)
Discussion started by: jiam912
8 Replies
QGridLayout(3qt)														  QGridLayout(3qt)

NAME
QGridLayout - Lays out widgets in a grid SYNOPSIS
#include <qlayout.h> Inherits QLayout. Public Members QGridLayout ( QWidget * parent, int nRows = 1, int nCols = 1, int margin = 0, int space = -1, const char * name = 0 ) QGridLayout ( int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 ) QGridLayout ( QLayout * parentLayout, int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 ) ~QGridLayout () virtual QSize sizeHint () const virtual QSize minimumSize () const virtual QSize maximumSize () const virtual void setRowStretch ( int row, int stretch ) virtual void setColStretch ( int col, int stretch ) int rowStretch ( int row ) const int colStretch ( int col ) const int numRows () const int numCols () const QRect cellGeometry ( int row, int col ) const virtual bool hasHeightForWidth () const virtual int heightForWidth ( int w ) const virtual QSizePolicy::ExpandData expanding () const virtual void invalidate () virtual void addItem ( QLayoutItem * item ) void addItem ( QLayoutItem * item, int row, int col ) void addMultiCell ( QLayoutItem * item, int fromRow, int toRow, int fromCol, int toCol, int alignment = 0 ) void addWidget ( QWidget * w, int row, int col, int alignment = 0 ) void addMultiCellWidget ( QWidget * w, int fromRow, int toRow, int fromCol, int toCol, int alignment = 0 ) void addLayout ( QLayout * layout, int row, int col ) void addMultiCellLayout ( QLayout * layout, int fromRow, int toRow, int fromCol, int toCol, int alignment = 0 ) void addRowSpacing ( int row, int minsize ) void addColSpacing ( int col, int minsize ) void expand ( int nRows, int nCols ) enum Corner { TopLeft, TopRight, BottomLeft, BottomRight } void setOrigin ( Corner c ) Corner origin () const virtual void setGeometry ( const QRect & r ) Protected Members bool findWidget ( QWidget * w, int * row, int * col ) void add ( QLayoutItem * item, int row, int col ) DESCRIPTION
The QGridLayout class lays out widgets in a grid. QGridLayout takes the space made available to it (by its parent layout or by the mainWidget()), divides it up into rows and columns, and puts each widget it manages into the correct cell. Columns and rows behave identically; we will discuss columns, but there are equivalent functions for rows. Each column has a minimum width and a stretch factor. The minimum width is the greatest of that set using addColSpacing() and the minimum width of each widget in that column. The stretch factor is set using setColStretch() and determines how much of the available space the column will get over and above its necessary minimum. Normally, each managed widget or layout is put into a cell of its own using addWidget(), addLayout() or by the auto-add facility. It is also possible for a widget to occupy multiple cells using addMultiCellWidget(). If you do this, QGridLayout will guess how to distribute the size over the columns/rows (based on the stretch factors). To remove a widget from a layout, call removeWidget(). Calling QWidget::hide() on a widget also effectively removes the widget from the layout until QWidget::show() is called. This illustration shows a fragment of a dialog with a five-column, three-row grid (the grid is shown overlaid in magenta): <center> [Image Omitted] </center> Columns 0, 2 and 4 in this dialog fragment are made up of a QLabel, a QLineEdit, and a QListBox. Columns 1 and 3 are placeholders made with addColSpacing(). Row 0 consists of three QLabel objects, row 1 of three QLineEdit objects and row 2 of three QListBox objects. We used placeholder columns (1 and 3) to get the right amount of space between the columns. Note that the columns and rows are not equally wide or tall. If you want two columns to have the same width, you must set their minimum widths and stretch factors to be the same yourself. You do this using addColSpacing() and setColStretch(). If the QGridLayout is not the top-level layout (i.e. does not manage all of the widget's area and children), you must add it to its parent layout when you create it, but before you do anything with it. The normal way to add a layout is by calling parentLayout->addLayout(). Once you have added your layout you can start putting widgets and other layouts into the cells of your grid layout using addWidget(), addLayout() and addMultiCellWidget(). QGridLayout also includes two margin widths: the border and the spacing. The border is the width of the reserved space along each of the QGridLayout's four sides. The spacing is the width of the automatically allocated spacing between neighboring boxes. Both the border and the spacing are parameters of the constructor and default to 0. See also QGrid, Layout Overview, Widget Appearance and Style, and Layout Management. Member Type Documentation QGridLayout::Corner This enum identifies which corner is the origin (0, 0) of the layout. QGridLayout::TopLeft - the top-left corner QGridLayout::TopRight - the top-right corner QGridLayout::BottomLeft - the bottom-left corner QGridLayout::BottomRight - the bottom-right corner MEMBER FUNCTION DOCUMENTATION
QGridLayout::QGridLayout ( QWidget * parent, int nRows = 1, int nCols = 1, int margin = 0, int space = -1, const char * name = 0 ) Constructs a new QGridLayout with nRows rows, nCols columns and parent widget, parent. parent may not be 0. The grid layout is called name. margin is the number of pixels between the edge of the widget and its managed children. space is the default number of pixels between cells. If space is -1, the value of margin is used. QGridLayout::QGridLayout ( int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 ) Constructs a new grid with nRows rows and nCols columns. If spacing is -1, this QGridLayout inherits its parent's spacing(); otherwise spacing is used. The grid layout is called name. You must insert this grid into another layout. You can insert widgets and layouts into this layout at any time, but laying out will not be performed before this is inserted into another layout. QGridLayout::QGridLayout ( QLayout * parentLayout, int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 ) Constructs a new grid that is placed inside parentLayout with nRows rows and nCols columns. If spacing is -1, this QGridLayout inherits its parent's spacing(); otherwise spacing is used. The grid layout is called name. This grid is placed according to parentLayout's default placement rules. QGridLayout::~QGridLayout () Destroys the grid layout. Geometry management is terminated if this is a top-level grid. The layout's widgets aren't destroyed. void QGridLayout::add ( QLayoutItem * item, int row, int col ) [protected] Adds item at position row, col. The layout takes ownership of the item. void QGridLayout::addColSpacing ( int col, int minsize ) Sets the minimum width of column col to minsize pixels. void QGridLayout::addItem ( QLayoutItem * item, int row, int col ) Adds item at position row, col. The layout takes ownership of the item. void QGridLayout::addItem ( QLayoutItem * item ) [virtual] This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Adds item to the next free position of this layout. Reimplemented from QLayout. void QGridLayout::addLayout ( QLayout * layout, int row, int col ) Places the layout at position (row, col) in the grid. The top-left position is (0, 0). Examples: void QGridLayout::addMultiCell ( QLayoutItem * item, int fromRow, int toRow, int fromCol, int toCol, int alignment = 0 ) Adds the item to the cell grid, spanning multiple rows/columns. The cell will span from fromRow, fromCol to toRow, toCol. Alignment is specified by alignment, which is a bitwise OR of Qt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell. void QGridLayout::addMultiCellLayout ( QLayout * layout, int fromRow, int toRow, int fromCol, int toCol, int alignment = 0 ) Adds the layout layout to the cell grid, spanning multiple rows/columns. The cell will span from fromRow, fromCol to toRow, toCol. Alignment is specified by alignment, which is a bitwise OR of Qt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell. A non-zero alignment indicates that the layout should not grow to fill the available space but should be sized according to sizeHint(). void QGridLayout::addMultiCellWidget ( QWidget * w, int fromRow, int toRow, int fromCol, int toCol, int alignment = 0 ) Adds the widget w to the cell grid, spanning multiple rows/columns. The cell will span from fromRow, fromCol to toRow, toCol. Alignment is specified by alignment, which is a bitwise OR of Qt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell. A non-zero alignment indicates that the widget should not grow to fill the available space but should be sized according to sizeHint(). Examples: void QGridLayout::addRowSpacing ( int row, int minsize ) Sets the minimum height of row row to minsize pixels. void QGridLayout::addWidget ( QWidget * w, int row, int col, int alignment = 0 ) Adds the widget w to the cell grid at row, col. The top-left position is (0, 0) by default. Alignment is specified by alignment, which is a bitwise OR of Qt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell. You should not call this if you have enabled the auto-add facility of the layout. From Qt 3.0, the alignment parameter is interpreted more aggressively than in previous versions of Qt. A non-default alignment now indicates that the widget should not grow to fill the available space, but should be sized according to sizeHint(). Examples: QRect QGridLayout::cellGeometry ( int row, int col ) const Returns the geometry of the cell with row row and column col in the grid. Returns an invalid rectangle if row or col is outside the grid. Warning: in the current version of Qt this function does not return valid results until setGeometry() has been called, i.e. after the mainWidget() is visible. int QGridLayout::colStretch ( int col ) const Returns the stretch factor for column col. See also setColStretch(). void QGridLayout::expand ( int nRows, int nCols ) Expands this grid so that it will have nRows rows and nCols columns. Will not shrink the grid. You should not need to call this function because QGridLayout expands automatically as new items are inserted. QSizePolicy::ExpandData QGridLayout::expanding () const [virtual] Returns whether this layout can make use of more space than sizeHint(). A value of Vertical or Horizontal means that it wants to grow in only one dimension, whereas BothDirections means that it wants to grow in both dimensions. Reimplemented from QLayout. bool QGridLayout::findWidget ( QWidget * w, int * row, int * col ) [protected] Searches for widget w in this layout (not including child layouts). If w is found, it sets *<em>row</em> and *<em>col</em> to the row and column and returns TRUE; otherwise returns FALSE. Note: if a widget spans multiple rows/columns, the top-left cell is returned. bool QGridLayout::hasHeightForWidth () const [virtual] Returns TRUE if this layout's preferred height depends on its width; otherwise returns FALSE. Reimplemented from QLayoutItem. int QGridLayout::heightForWidth ( int w ) const [virtual] Returns the layout's preferred height when it is w pixels wide. Reimplemented from QLayoutItem. void QGridLayout::invalidate () [virtual] Resets cached information. Reimplemented from QLayout. QSize QGridLayout::maximumSize () const [virtual] Returns the maximum size needed by this grid. Reimplemented from QLayout. QSize QGridLayout::minimumSize () const [virtual] Returns the minimum size needed by this grid. Reimplemented from QLayout. int QGridLayout::numCols () const Returns the number of columns in this grid. int QGridLayout::numRows () const Returns the number of rows in this grid. Corner QGridLayout::origin () const Returns the corner that's used for the grid's origin, i.e. for position (0, 0). int QGridLayout::rowStretch ( int row ) const Returns the stretch factor for row row. See also setRowStretch(). void QGridLayout::setColStretch ( int col, int stretch ) [virtual] Sets the stretch factor of column col to stretch. The first column is number 0. The stretch factor is relative to the other columns in this grid. Columns with a higher stretch factor take more of the available space. The default stretch factor is 0. If the stretch factor is 0 and no other column in this table can grow at all, the column may still grow. See also colStretch(), addColSpacing(), and setRowStretch(). Examples: void QGridLayout::setGeometry ( const QRect & r ) [virtual] Resizes managed widgets within the rectangle r. Reimplemented from QLayout. void QGridLayout::setOrigin ( Corner c ) Sets the grid's origin corner, i.e. position (0, 0), to c. void QGridLayout::setRowStretch ( int row, int stretch ) [virtual] Sets the stretch factor of row row to stretch. The first row is number 0. The stretch factor is relative to the other rows in this grid. Rows with a higher stretch factor take more of the available space. The default stretch factor is 0. If the stretch factor is 0 and no other row in this table can grow at all, the row may still grow. See also rowStretch(), addRowSpacing(), and setColStretch(). Example: addressbook/centralwidget.cpp. QSize QGridLayout::sizeHint () const [virtual] Returns the preferred size of this grid. Reimplemented from QLayoutItem. SEE ALSO
http://doc.trolltech.com/qgridlayout.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qgridlayout.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QGridLayout(3qt)
All times are GMT -4. The time now is 12:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy