I am creating a report in groff and need to format data from a file into a
table cell.
Sample data:
I would like to build a table such that the first column contains unique
data from the second column of the file. The second column would contain
data associated with unique item in column one:
example:
<tr>
<td>173323</td><td>jsp, nj, b, nb</td>
</tr>
<tr>
<td>360356</td><td>nj, b, nb, mjcd</td>
</tr>
My main issue is the second column cells as a matrix of data from a single
array should be printed between groff's T{ T} table macros.
example:
So, to print a simple matrix I remember you can do something like:
But how could you print a matrix using a single array pulled from a file.
I've got the file read and the array created ...but how to I print it in a
4x? grid/matrix?
Would an awk script be more efficient for pulling this data and printing it
this way?
Hello guys,
I have in PERL an associative 2-dimensional array, called matrix. The array (actually the matrix) is made up like this
matrix = x;
matrix = y;
matrix = w;
matrix = z;
...
but the names a, b, c, d are set just at runtime.
The question is: how can i get all the keys of... (2 Replies)
Hi Guys,
I have an array which has numbers including blanks as follows:
1
26
66
4.77
-0.58
88
99
11
12
333
I want to print a group of three elements as a different column in a file as follows:(including blanks where there is missing elements) for.e.g. array element #7... (4 Replies)
I'm trying to create a Matrix using bash. The expected output is
.AB CDE FG
1
2
3
4
5
6
7
I'm a newbie in shell language, really appreciate if there is anyone who can guide me with this.
Double post again, continued here (0 Replies)
I have a file like this:
ASSPASVFETQY,hTRBV12-4,hTRBJ2-5,2
ASSPASTGGDYGYT,hTRBV18,hTRBJ1-2,2
ASSPASGDGYT,hTRBV5-1,hTRBJ1-2,2
ASSPASFPEDTQY,hTRBV27,hTRBJ2-3,2
ASSPARVNYGYT,hTRBV5-1,hTRBJ1-2,2
ASSPARTSGGLNEQF,hTRBV6-4,hTRBJ2-1,2
ASSPARQSYNEQF,hTRBV11-1,hTRBJ2-1,2... (3 Replies)
Hi all,
I been looking for a solution to the fact that when I use:
for (i=1; i<=NF; i++) print $ifields that are originally in a single line are printed in a single line
I have severals files for which the first 7 are the same, but the number of variables after that can vary, for example NF... (5 Replies)
First of I would just like to state that I am not looking for you guys to just do my work for me, I do want to learn and actually understand everything that is happening.
Hey all, I am having trouble on this. What I need to do is... Write an executable C file that will take a text file (not a... (8 Replies)
#!/bin/bash
PH=(AD QD QC 5H 6C 8C 7D JH 3H 3S)
echo ${PH}
In the above array, how can I print to screen just the first 8 elements of ${PH} and have the last 2 elements print just below the first line starting underneath AD?
I need to do this in order to save terminal window spacing... (5 Replies)
I use the following script to print the sum and how could I extend this to print medians instead? thanks
name s1 s2 s3 s4
g1 2 8 6 5
g1 5 7 9 9
g1 6 7 8 9
g2 8 8 8 8
g2 7 7 7 7
g2 10 10 10 10
g3 3 12 1 24
g3 5 5 24 48
g3 12 3 12 12
g3 2 3 3 3
output
name s1 s2 s3 s4
g1 5 7 8 9... (5 Replies)
Discussion started by: quincyjones
5 Replies
LEARN ABOUT DEBIAN
rtbl_add_column_entry_by_id
RTBL(3) BSD Library Functions Manual RTBL(3)NAME
rtbl_create, rtbl_destroy, rtbl_set_flags, rtbl_get_flags, rtbl_set_prefix, rtbl_set_separator, rtbl_set_column_prefix,
rtbl_set_column_affix_by_id, rtbl_add_column, rtbl_add_column_by_id, rtbl_add_column_entry, rtbl_add_column_entry_by_id, rtbl_new_row,
rtbl_format -- format data in simple tables
LIBRARY
The roken library (libroken, -lroken)
SYNOPSIS
#include <rtbl.h>
int
rtbl_add_column(rtbl_t table, const char *column_name, unsigned int flags);
int
rtbl_add_column_by_id(rtbl_t table, unsigned int column_id, const char *column_header, unsigned int flags);
int
rtbl_add_column_entry(rtbl_t table, const char *column_name, const char *cell_entry);
int
rtbl_add_column_entry_by_id(rtbl_t table, unsigned int column_id, const char *cell_entry);
rtbl_t
rtbl_create(void);
void
rtbl_destroy(rtbl_t table);
int
rtbl_new_row(rtbl_t table);
int
rtbl_set_column_affix_by_id(rtbl_t table, unsigned int column_id, const, char, *prefix", const char *suffix);
int
rtbl_set_column_prefix(rtbl_t table, const char *column_name, const char *prefix);
unsigned int
rtbl_get_flags(rtbl_t table);
void
rtbl_set_flags(rtbl_t table, unsigned int flags);
int
rtbl_set_prefix(rtbl_t table, const char *prefix);
int
rtbl_set_separator(rtbl_t table, const char *separator);
int
rtbl_format(rtbl_t table, FILE, *file");
DESCRIPTION
This set of functions assemble a simple table consisting of rows and columns, allowing it to be printed with certain options. Typical use
would be output from tools such as ls(1) or netstat(1), where you have a fixed number of columns, but don't know the column widths before
hand.
A table is created with rtbl_create() and destroyed with rtbl_destroy().
Global flags on the table are set with rtbl_set_flags and retrieved with rtbl_get_flags. At present the only defined flag is
RTBL_HEADER_STYLE_NONE which suppresses printing the header.
Before adding data to the table, one or more columns need to be created. This would normally be done with rtbl_add_column_by_id(), column_id
is any number of your choice (it's used only to identify columns), column_header is the header to print at the top of the column, and flags
are flags specific to this column. Currently the only defined flag is RTBL_ALIGN_RIGHT, aligning column entries to the right. Columns are
printed in the order they are added.
There's also a way to add columns by column name with rtbl_add_column(), but this is less flexible (you need unique header names), and is
considered deprecated.
To add data to a column you use rtbl_add_column_entry_by_id(), where the column_id is the same as when the column was added (adding data to a
non-existent column is undefined), and cell_entry is whatever string you wish to include in that cell. It should not include newlines. For
columns added with rtbl_add_column() you must use rtbl_add_column_entry() instead.
rtbl_new_row() fills all columns with blank entries until they all have the same number of rows.
Each column can have a separate prefix and suffix, set with rtbl_set_column_affix_by_id; rtbl_set_column_prefix allows setting the prefix
only by column name. In addition to this, columns may be separated by a string set with rtbl_set_separator (by default columns are not
seprated by anything).
The finished table is printed to file with rtbl_format.
EXAMPLES
This program:
#include <stdio.h>
#include <rtbl.h>
int
main(int argc, char **argv)
{
rtbl_t table;
table = rtbl_create();
rtbl_set_separator(table, " ");
rtbl_add_column_by_id(table, 0, "Column A", 0);
rtbl_add_column_by_id(table, 1, "Column B", RTBL_ALIGN_RIGHT);
rtbl_add_column_by_id(table, 2, "Column C", 0);
rtbl_add_column_entry_by_id(table, 0, "A-1");
rtbl_add_column_entry_by_id(table, 0, "A-2");
rtbl_add_column_entry_by_id(table, 0, "A-3");
rtbl_add_column_entry_by_id(table, 1, "B-1");
rtbl_add_column_entry_by_id(table, 2, "C-1");
rtbl_add_column_entry_by_id(table, 2, "C-2");
rtbl_add_column_entry_by_id(table, 1, "B-2");
rtbl_add_column_entry_by_id(table, 1, "B-3");
rtbl_add_column_entry_by_id(table, 2, "C-3");
rtbl_add_column_entry_by_id(table, 0, "A-4");
rtbl_new_row(table);
rtbl_add_column_entry_by_id(table, 1, "B-4");
rtbl_new_row(table);
rtbl_add_column_entry_by_id(table, 2, "C-4");
rtbl_new_row(table);
rtbl_format(table, stdout);
rtbl_destroy(table);
return 0;
}
will output the following:
Column A Column B Column C
A-1 B-1 C-1
A-2 B-2 C-2
A-3 B-3 C-3
A-4
B-4
C-4
HEIMDAL June 26, 2004 HEIMDAL