1TABMERGE(1)           User Contributed Perl Documentation          TABMERGE(1)
2
3
4

NAME

6       tabmerge - unify delimited files on common fields
7

SYNOPSIS

9         tabmerge [action] [options] file1 file2 [...]
10
11       Actions:
12
13         --min                Take only fields present in all files [DEFAULT]
14         --max                Take all fields present
15         -f|--fields=f1[,f2]  Take only the fields mentioned in the
16                              comma-separated list
17
18       Options:
19
20         -l|--list            List available fields
21         --fs=x               Use "x" as the field separator
22                              (default is tab "\t")
23         --rs=x               Use "x" as the record separator
24                              (default is newline "\n")
25         -s|--sort=f1[,f2]    Sort data ASCII-betically on field(s)
26         --stdout             Print data in original delimited format
27                              (i.e., not in a table format)
28
29         --help               Show brief help and quit
30         --man                Show full documentation
31

DESCRIPTION

33       This program merges the fields -- not the rows -- of delimited text
34       files.  That is, if several files are almost but not quite entirely
35       unlike each other in their structure (in their field names, numbers or
36       orders), this script allows you to easily unify the files into one file
37       with all the same fields.  The output can be based on fields as
38       determined by the three "action" flags.
39
40       For the following examples, consider three files that contain the
41       following fields:
42
43         +------------+---------------------------------+
44         | File       | Fields                          |
45         +------------+---------------------------------+
46         | merge1.tab | name, type, position            |
47         | merge2.tab | name, type, position, lod_score |
48         | merge3.tab | name, position                  |
49         +------------+---------------------------------+
50
51       To list all available fields in the files and the number of times they
52       are present:
53
54         $ tabmerge --list merge*
55         +-----------+-------------------+
56         | Field     | No. Times Present |
57         +-----------+-------------------+
58         | lod_score | 1                 |
59         | name      | 3                 |
60         | position  | 3                 |
61         | type      | 2                 |
62         +-----------+-------------------+
63
64       To merge the files on the minimum overlapping fields:
65
66         $ tabmerge merge*
67         +----------+----------+
68         | name     | position |
69         +----------+----------+
70         | RM104    | 2.30     |
71         | RM105    | 4.5      |
72         | TX5509   | 10.4     |
73         | UU189    | 19.0     |
74         | Xpsm122  | 3.3      |
75         | Xpsr9556 | 4.5      |
76         | DRTL     | 2.30     |
77         | ALTX     | 4.5      |
78         | DWRF     | 10.4     |
79         +----------+----------+
80
81       To merge the files and include all the fields:
82
83         $ tabmerge --max merge*
84         +-----------+----------+----------+--------+
85         | lod_score | name     | position | type   |
86         +-----------+----------+----------+--------+
87         |           | RM104    | 2.30     | RFLP   |
88         |           | RM105    | 4.5      | RFLP   |
89         |           | TX5509   | 10.4     | AFLP   |
90         | 2.4       | UU189    | 19.0     | SSR    |
91         | 1.2       | Xpsm122  | 3.3      | Marker |
92         | 1.2       | Xpsr9556 | 4.5      | Marker |
93         |           | DRTL     | 2.30     |        |
94         |           | ALTX     | 4.5      |        |
95         |           | DWRF     | 10.4     |        |
96         +-----------+----------+----------+--------+
97
98       To merge and extract just the "name" and "type" fields:
99
100         $ tabmerge -f name,type merge*
101         +----------+--------+
102         | name     | type   |
103         +----------+--------+
104         | RM104    | RFLP   |
105         | RM105    | RFLP   |
106         | TX5509   | AFLP   |
107         | UU189    | SSR    |
108         | Xpsm122  | Marker |
109         | Xpsr9556 | Marker |
110         | DRTL     |        |
111         | ALTX     |        |
112         | DWRF     |        |
113         +----------+--------+
114
115       To merge the files on just the "name" and "lod_score" fields and sort
116       on the name:
117
118         $ tabmerge -f name,lod_score -s name merge*
119         +----------+-----------+
120         | name     | lod_score |
121         +----------+-----------+
122         | ALTX     |           |
123         | DRTL     |           |
124         | DWRF     |           |
125         | RM104    |           |
126         | RM105    |           |
127         | TX5509   |           |
128         | UU189    | 2.4       |
129         | Xpsm122  | 1.2       |
130         | Xpsr9556 | 1.2       |
131         +----------+-----------+
132
133       To do the same but mimic the original tab-delimited input:
134
135         $ tabmerge -f name,lod_score -s name --stdout merge*
136         name    lod_score
137         ALTX
138         DRTL
139         DWRF
140         RM104
141         RM105
142         TX5509
143         UU189   2.4
144         Xpsm122 1.2
145         Xpsr9556        1.2
146
147       Why would you want to do this?  Suppose you have several delimited text
148       files with nearly the same structure and want to create just one file
149       from them, but the fields may be in a different order in each file
150       and/or some files may contain more or fewer fields than others.  (As
151       far-fetched as it may seem, it happens to the author more than he'd
152       like.)
153

SEE ALSO

155       •   Text::RecordParser
156
157       •   Text::TabularDisplay
158

AUTHOR

160       Ken Youens-Clark <kclark@cpan.org>.
161
163       Copyright (C) 2006-10 Ken Youens-Clark.  All rights reserved.
164
165       This program is free software; you can redistribute it and/or modify it
166       under the terms of the GNU General Public License as published by the
167       Free Software Foundation; version 2.
168
169       This program is distributed in the hope that it will be useful, but
170       WITHOUT ANY WARRANTY; without even the implied warranty of
171       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
172       General Public License for more details.
173
174
175
176perl v5.32.1                      2021-01-27                       TABMERGE(1)
Impressum