Sponsored Content
Full Discussion: Reformat text table
Top Forums Shell Programming and Scripting Reformat text table Post 302486506 by yifangt on Sunday 9th of January 2011 12:33:48 AM
Old 01-09-2011
Reformat text table

Hello,

I have a challenge here to reformat a text table. The original table follows:
Code:
Item01: m1, m2, m3: A; m4, m5, m6: B; m7, m8: C; m9 m10: D
Item02: m1, m9, m10: A; m7, m5, m6: C; m2, m3, m4, m8: D
Item03: m1, m6, m7: A; m2: B; m3, m4: C; m5 m8 m9 m10: D
.
.
.

Please note:
1) m1, m2, ~ m10 show up each row, always!
2) m1~m10 may be in random order;
3) A, B, C, D may NOT always show up in each row;

I want the table reformatted to:
Code:
        m1   m2   m3   m4   m5   m6   m7   m8   m9   m10
Item01  A    A    A    B    B    B    C    C    D    D
Item02  A    D    D    D    C    C    C    D    A    A
Item03  A    B    C    C    D    A    A    D    D    D

.
.
.

which mean with a header as the first row (m1 ~ m10) and the Item-- as the first column. The reformatted one is a two dimension structure that is much easier to look at.

I have been struggling with it using PERL by myself for a long time. Could not figure it out. Any help is highly appreciated. Thanks in advance!

Yifangt

Last edited by Scott; 01-09-2011 at 03:29 AM.. Reason: Code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how can I bcp out a table into a text file including the header row in the text file

Hi All, I need to BCP out a table into a text file along with the table headers. Normal BCP out command only bulk copies the data, and not the headers. I am using the following command: bcp database1..table1 out file1.dat -c -t\| -b1000 -A8192 -Uuser -Ppassword -efile.dat.err Regards,... (0 Replies)
Discussion started by: shilpa_acc
0 Replies

2. Shell Programming and Scripting

awk to reformat a text file

I am definitely not an expert with awk, and I want to reformat a text file like the following. This is probably a very easy one for an expert out there. I would like to keep the lines in the same order, but move the heading to only be listed once above the lines. This is what the text file... (7 Replies)
Discussion started by: linux4life
7 Replies

3. Shell Programming and Scripting

Help in script - Getting table name from a text file

hhhhhhhhhh (5 Replies)
Discussion started by: sams
5 Replies

4. Shell Programming and Scripting

Make a table from a text file

Hi, I have a pipe separated text file. Can some someone tell me how to convert it to a table? Text File contents. |Activities|Status1|Status2|Status3| ||NA|$io_running2|$io_running3| |Replication Status|NA|$running2|$running3| ||NA|$master2|$master3|... (1 Reply)
Discussion started by: rocky88
1 Replies

5. Shell Programming and Scripting

Normal text to table format

Hi, I am trying to show my list, from a simple list format to a table (row and column formatted table) Currently i have this format in my output (the formart it will always be like this ) >> first 3 lines must be on the same line aligned, and the next 3 shud be on 2nd line....: INT1:... (10 Replies)
Discussion started by: eboye
10 Replies

6. Shell Programming and Scripting

awk to reformat text

I have this input and want output like below, how can I achieve that through awk: Input: CAT1 FRY-01 CAT1 FRY-04 CAT1 DRY-03 CAT1 FRY-02 CAT1 DRY-04 CAT2 FRY-03 CAT2 FRY-02 CAT2 DRY-01 FAT3 DRY-12 FAT3 FRY-06 Output: category CAT1 item FRY-01 (7 Replies)
Discussion started by: aydj
7 Replies

7. UNIX for Dummies Questions & Answers

Loading text file into table

Hi, I have text file with comma seprater shown below lu8yh,n,Fri,Feb,7,2014,16:5 deer4 deer4,n,Tue,Aug,21,,2012,on r43ed r43ed,n,Tue,Nov,12,2013,12: e43sd e43sd,n,Tue,Jan,1,,2013,on, I am using below code to load the text file into table #!/bin/ksh... (16 Replies)
Discussion started by: stew
16 Replies

8. UNIX for Dummies Questions & Answers

Deleting unwanted text from a table

Hi everyone, I have a microbial diversity table in the format ;k__kingdom; p__phylum, etc, somer rows have descriptions before the :k__ (like the af028349.1 below) is there a way I can get rid of this text (which is different every time) and keep all the other columns? Thanks a bunch! ;... (1 Reply)
Discussion started by: Juan Gonzalez
1 Replies

9. Shell Programming and Scripting

awk to reformat text file

Howdy. AWK beginner here. I need to reformat a text file in the following format: TTGS08-2014001 6018.00 143563.00 ... (2 Replies)
Discussion started by: c47v3770
2 Replies
dwfilter(1)						   reformat text for processing 					       dwfilter(1)

NAME
dwfilter - reformat text with dwdiff for further processing SYNOPSIS
dwfilter [OPTIONS] <OLD FILE> <NEW FILE> <POST PROCESSOR> [POST PROCESSOR OPTIONS] DESCRIPTION
dwfilter reformats the text in the old file according to the contents of the new file (or vice versa) and subsequently passes the refor- mated old file and the new file through a secondary filter. It's main use is to allow visual diff programs such as meld and kdiff3 to be used, eventhough a text file has been reformated after editing. A further use is to allow the creation of small patches even when the new text has been reformated. dwfilter uses dwdiff for reformatting. OPTIONS
-r, --reverse Reformat the new file based on the contents of the old file instead of the default where the old file is reformated based on the contents of the new file. dwfilter accepts the following dwdiff options: -d <delimiters>, --delimiters=<delimiters> -P, --punctuation> -W <whitespace>, --whitespace=<whitespace> -i, --ignore-case -I, --ignore-formatting -D <option>, --diff-option=<option> -C<num>, --context=<num> -m<num>, --match-context=<num> --aggregate-changes --wdiff-output See the dwdiff manual page for the meaning. A single dash (-) as a file can be used to denote standard input. Only one file can be read from standard input. To stop dwfilter from interpreting file names that start with a dash as options, one can specify a double dash (--) after which dwfilter will interpret any fol- lowing arguments as files to read. BUGS
If you think you have found a bug, please check that you are using the latest version of dwdiff [http://os.ghalkes.nl/dwdiff.html]. When reporting bugs, please include a minimal example that demonstrates the problem. AUTHOR
G.P. Halkes <dwdiff@ghalkes.nl> COPYRIGHT
Copyright (C) 2006-2010 G.P. Halkes dwdiff is licensed under the GNU General Public License version 3. For more details on the license, see the file COPYING in the documentation directory. On Un*x systems this is usually /usr/share/doc/dwdiff-2.0.4. SEE ALSO
dwdiff(1), diff(1), meld(1), kdiff3(1) Version 2.0.4 12-06-2012 dwfilter(1)
All times are GMT -4. The time now is 06:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy