Hello gurus,
I have a file containing 5 columns delimited by '#' as shown in the example below:
The first row contains the the header, which I would like to remove in the final output, which should look like below:
Field lengths should be as follows:
Column 1 = 8 (1-8)
Column 2 = 6 (10-15)
Column 3 = 10 (17-26)
Column 4 = 5 (28-32)
Column 5 = 30 (34-63)
Any help on a code to perform this conversion will be greatly appreciated.
Thanks!
Last edited by Franklin52; 07-07-2011 at 03:15 AM..
Reason: Please use code tags for code and data samples, thank you
Hi, I have to change a tab delimited file to a fixed length file. For text fields I need to left justify and NULL fill to the right and for number fields I need to right justify and zero fill to the left. If there are spaces between words in a text field I need to keep them as spaces. I am using... (14 Replies)
Hi,
I have a delimited file generated by a database and i need to convert it to fixed width file using the field length of the database. Can any body suggest me how can i proceed with it?
:confused:
Thanks
Raghavan (2 Replies)
I have below fixed lenth file . I have to convert this to delimitted file.
File1.txtE116005/29/19930E001E000
E12201/23/19940E001E003
E10406/4/19940E001E003
I want to convert this to :
E116,0,05/29/1993,0,E001,E000
E122,0,1/23/1994,0,E001,E003
E104,0,6/4/1994,0,E001,E003
I have a... (7 Replies)
Hi, Iam new to unix. I have one input file .
Input file :
ID1~Name1~Place1
ID2~Name2~Place2
ID3~Name3~Place3
I need output such that only first column should change to fixed width column of 15 characters of length.
Output File:
ID1<<12 spaces>>Name1~Place1
ID2<<12... (5 Replies)
Hello Gurus,
I have a text file containing nearly 12,000 tab delimited characters with 4000 rows. If the file size is small, excel can convert the text into coloumns. However, the file that I have is very big. Can some body help me in solving this problem?
The input file example,
... (6 Replies)
Hi,
I have a fixed width text file without any header row. One of the columns contains a date in YYYYMMDD format.
If the original file contains 3 dates, I want my shell script to split the file into 3 small files with data for each date.
I am a newbie and need help doing this. (14 Replies)
Hello gurus,
I have a file in a tab delimited format and a header row. I need a code to delete the header in the file, and convert the file to a fixed width format, with all the columns aligned. Below is a sample of the file:... (4 Replies)
I have a file with different record length. The file as to be converted into fixed length by appending spaces at the end of record. The length should be calculated based on the record with maximum length in the file.
If the length is less than the max length, the spaces should be appended... (4 Replies)
Hi, I have a rquirement in unix as below .
I have a text file with me seperated by | symbol and i need to generate a excel file through unix commands/script so that each value will go to each column.
ex:
Input Text file:
1|A|apple
2|B|bottle
excel file to be generated as output as... (9 Replies)
Hi - this is a generic question .... is there any utility which can convert a fixed width file format to a delimited file (any given character delimited) ? (5 Replies)
Discussion started by: i4ismail
5 Replies
LEARN ABOUT DEBIAN
rtbl_add_column_entry
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