0
|
1 <html>
|
|
2 <head>
|
|
3 <title>MayaChemTools:Documentation:MergeTextFiles.pl</title>
|
|
4 <meta http-equiv="content-type" content="text/html;charset=utf-8">
|
|
5 <link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css">
|
|
6 </head>
|
|
7 <body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10">
|
|
8 <br/>
|
|
9 <center>
|
|
10 <a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a>
|
|
11 </center>
|
|
12 <br/>
|
|
13 <div class="DocNav">
|
|
14 <table width="100%" border=0 cellpadding=0 cellspacing=2>
|
|
15 <tr align="left" valign="top"><td width="33%" align="left"><a href="./MACCSKeysFingerprints.html" title="MACCSKeysFingerprints.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./MergeTextFilesWithSD.html" title="MergeTextFilesWithSD.html">Next</a></td><td width="34%" align="middle"><strong>MergeTextFiles.pl</strong></td><td width="33%" align="right"><a href="././code/MergeTextFiles.html" title="View source code">Code</a> | <a href="./../pdf/MergeTextFiles.pdf" title="PDF US Letter Size">PDF</a> | <a href="./../pdfgreen/MergeTextFiles.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a> | <a href="./../pdfa4/MergeTextFiles.pdf" title="PDF A4 Size">PDFA4</a> | <a href="./../pdfa4green/MergeTextFiles.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr>
|
|
16 </table>
|
|
17 </div>
|
|
18 <p>
|
|
19 </p>
|
|
20 <h2>NAME</h2>
|
|
21 <p>MergeTextFiles.pl - Merge multiple CSV or TSV text files into a single text file</p>
|
|
22 <p>
|
|
23 </p>
|
|
24 <h2>SYNOPSIS</h2>
|
|
25 <p>MergeTextFiles.pl TextFiles...</p>
|
|
26 <p>MergeTextFiles.pl [<strong>-h, --help</strong>] [<strong>--indelim</strong> comma | semicolon] [<strong>-c, --columns</strong> colnum,...;... | collabel,...;...]
|
|
27 [<strong>-k, --keys</strong> colnum,...;... | collabel,...;...] [<strong>-m, --mode</strong> colnum | collabel]
|
|
28 [<strong>-o, --overwrite</strong>] [<strong>--outdelim</strong> comma | tab | semicolon] [<strong>-q, --quote</strong> yes | no]
|
|
29 [<strong>-r, --root</strong> rootname] [<strong>-s, --startcol</strong> colnum | collabel] [<strong>--startcolmode</strong> before | after]
|
|
30 [<strong>-w, --workingdir</strong> dirname] TextFiles...</p>
|
|
31 <p>
|
|
32 </p>
|
|
33 <h2>DESCRIPTION</h2>
|
|
34 <p>Merge multiple CSV or TSV <em>TextFiles</em> into first <em>TextFile</em> to generate a single
|
|
35 text file. Unless <strong>-k --keys</strong> option is used, data rows from other <em>TextFiles</em>
|
|
36 are added to first <em>TextFile</em> in a sequential order, and the number of rows in first
|
|
37 <em>TextFile</em> is used to determine how many rows of data are added from other
|
|
38 <em>TextFiles</em>.</p>
|
|
39 <p>Multiple <em>TextFiles</em> names are separated by space. The valid file extensions are <em>.csv</em> and
|
|
40 <em>.tsv</em> for comma/semicolon and tab delimited text files respectively. All other file names
|
|
41 are ignored. All the text files in a current directory can be specified by <em>*.csv</em>,
|
|
42 <em>*.tsv</em>, or the current directory name. The <strong>--indelim</strong> option determines the
|
|
43 format of <em>TextFiles</em>. Any file which doesn't correspond to the format indicated
|
|
44 by <strong>--indelim</strong> option is ignored.</p>
|
|
45 <p>
|
|
46 </p>
|
|
47 <h2>OPTIONS</h2>
|
|
48 <dl>
|
|
49 <dt><strong><strong>-h, --help</strong></strong></dt>
|
|
50 <dd>
|
|
51 <p>Print this help message.</p>
|
|
52 </dd>
|
|
53 <dt><strong><strong>--indelim</strong> <em>comma | semicolon</em></strong></dt>
|
|
54 <dd>
|
|
55 <p>Input delimiter for CSV <em>TextFile(s)</em>. Possible values: <em>comma or semicolon</em>.
|
|
56 Default value: <em>comma</em>. For TSV files, this option is ignored and <em>tab</em> is used as a
|
|
57 delimiter.</p>
|
|
58 </dd>
|
|
59 <dt><strong><strong>-c, --columns</strong> <em>colnum,...;... | collabel,...;...</em></strong></dt>
|
|
60 <dd>
|
|
61 <p>This value is mode specific. It is a list of columns to merge into first
|
|
62 text file specified by column numbers or labels for each text file
|
|
63 delimited by ";". All specified text files are merged into first text file.</p>
|
|
64 <p>Default value: <em>all;all;...</em>. By default, all columns from specified text files are
|
|
65 merged into first text file.</p>
|
|
66 <p>For <em>colnum</em> mode, input value format is: <em>colnum,...;colnum,...;...</em>. Example:</p>
|
|
67 <div class="OptionsBox">
|
|
68 "1,2;1,3,4;7,8,9"</div>
|
|
69 <p>For <em>collabel</em> mode, input value format is: <em>collabel,...;collabel,...;...</em>. Example:</p>
|
|
70 <div class="OptionsBox">
|
|
71 "MW,SumNO;SumNHOH,ClogP,PSA;MolName,Mol_Id,Extreg"</div>
|
|
72 </dd>
|
|
73 <dt><strong><strong>-k, --keys</strong> <em>colnum,...;... | collabel,...;...</em></strong></dt>
|
|
74 <dd>
|
|
75 <p>This value is mode specific. It specifies column keys to use for merging
|
|
76 all specified text files into first text file. The column keys are specified by
|
|
77 column numbers or labels for each text file delimited by ";".</p>
|
|
78 <p>By default, data rows from text files are merged into first file in the order they appear.</p>
|
|
79 <p>For <em>colnum</em> mode, input value format is:<em>colkeynum, colkeynum;...</em>. Example:</p>
|
|
80 <div class="OptionsBox">
|
|
81 "1;3;7"</div>
|
|
82 <p>For <em>collabel</em> mode, input value format is:<em>colkeylabel, colkeylabel;...</em>. Example:</p>
|
|
83 <div class="OptionsBox">
|
|
84 "Mol_Id;Mol_Id;Cmpd_Id"</div>
|
|
85 </dd>
|
|
86 <dt><strong><strong>-m, --mode</strong> <em>colnum | collabel</em></strong></dt>
|
|
87 <dd>
|
|
88 <p>Specify how to merge text files: using column numbers or column labels.
|
|
89 Possible values: <em>colnum or collabel</em>. Default value: <em>colnum</em>.</p>
|
|
90 </dd>
|
|
91 <dt><strong><strong>-o, --overwrite</strong></strong></dt>
|
|
92 <dd>
|
|
93 <p>Overwrite existing files.</p>
|
|
94 </dd>
|
|
95 <dt><strong><strong>--outdelim</strong> <em>comma | tab | semicolon</em></strong></dt>
|
|
96 <dd>
|
|
97 <p>Output text file delimiter. Possible values: <em>comma, tab, or semicolon</em>
|
|
98 Default value: <em>comma</em>.</p>
|
|
99 </dd>
|
|
100 <dt><strong><strong>-q, --quote</strong> <em>yes | no</em></strong></dt>
|
|
101 <dd>
|
|
102 <p>Put quotes around column values in output text file. Possible values: <em>yes or
|
|
103 no</em>. Default value: <em>yes</em>.</p>
|
|
104 </dd>
|
|
105 <dt><strong><strong>-r, --root</strong> <em>rootname</em></strong></dt>
|
|
106 <dd>
|
|
107 <p>New text file name is generated using the root: <Root>.<Ext>. Default file
|
|
108 name: <FirstTextFileName>1To<Count>Merged.<Ext>. The csv, and tsv
|
|
109 <Ext> values are used for comma/semicolon, and tab delimited text files
|
|
110 respectively.</p>
|
|
111 </dd>
|
|
112 <dt><strong><strong>-s, --startcol</strong> <em>colnum | collabel</em></strong></dt>
|
|
113 <dd>
|
|
114 <p>This value is mode specific. It specifies the column in first text file which is
|
|
115 used for start merging other text files.For <em>colnum</em> mode, specify column
|
|
116 number and for <em>collabel</em> mode, specify column label.</p>
|
|
117 <p>Default value: <em>last</em>. Start merge after the last column.</p>
|
|
118 </dd>
|
|
119 <dt><strong><strong>--startcolmode</strong> <em>before | after</em></strong></dt>
|
|
120 <dd>
|
|
121 <p>Start the merge before or after the <strong>-s, --startcol</strong> value. Possible values: <em>before or after</em>
|
|
122 Default value: <em>after</em>.</p>
|
|
123 </dd>
|
|
124 <dt><strong><strong>-w, --workingdir</strong> <em>dirname</em></strong></dt>
|
|
125 <dd>
|
|
126 <p>Location of working directory. Default: current directory.</p>
|
|
127 </dd>
|
|
128 </dl>
|
|
129 <p>
|
|
130 </p>
|
|
131 <h2>EXAMPLES</h2>
|
|
132 <p>To merge Sample2.csv and Sample3.csv into Sample1.csv and generate
|
|
133 NewSample.csv, type:</p>
|
|
134 <div class="ExampleBox">
|
|
135 % MergeTextFiles.pl -r NewSample -o Sample1.csv Sample2.csv
|
|
136 Sample3.csv</div>
|
|
137 <p>To merge all Sample*.tsv and generate NewSample.tsv file, type:</p>
|
|
138 <div class="ExampleBox">
|
|
139 % MergeTextFiles.pl -r NewSample --indelim comma --outdelim tab -o
|
|
140 Sample*.csv</div>
|
|
141 <p>To merge column numbers "1,2" and "3,4,5" from Sample2.csv and Sample3.csv
|
|
142 into Sample1.csv starting before column number 3 in Sample1.csv and to generate
|
|
143 NewSample.csv without quoting column data, type:</p>
|
|
144 <div class="ExampleBox">
|
|
145 % MergeTextFiles.pl -s 3 --startcolmode before -r NewSample -q no
|
|
146 -m colnum -c "all;1,2;3,4,5" -o Sample1.csv Sample2.csv
|
|
147 Sample3.csv</div>
|
|
148 <p>To merge column "Mol_ID,Formula,MolWeight" and "Mol_ID,NAME,ChemBankID"
|
|
149 from Sample2.csv and Sample3.csv into Sample1.csv using "Mol_ID" as a column keys
|
|
150 starting after the last column and to generate NewSample.tsv, type:</p>
|
|
151 <div class="ExampleBox">
|
|
152 % MergeTextFiles.pl -r NewSample --outdelim tab -k "Mol_ID;Mol_ID;
|
|
153 Mol_ID" -m collabel -c "all;Mol_ID,Formula,MolWeight;Mol_ID,NAME,
|
|
154 ChemBankID" -o Sample1.csv Sample2.csv Sample3.csv</div>
|
|
155 <p>
|
|
156 </p>
|
|
157 <h2>AUTHOR</h2>
|
|
158 <p><a href="mailto:msud@san.rr.com">Manish Sud</a></p>
|
|
159 <p>
|
|
160 </p>
|
|
161 <h2>SEE ALSO</h2>
|
|
162 <p><a href="./JoinTextFiles.html">JoinTextFiles.pl</a>, <a href="./MergeTextFilesWithSD.html">MergeTextFilesWithSD.pl</a>, <a href="./ModifyTextFilesFormat.html">ModifyTextFilesFormat.pl</a>, <a href="./SplitTextFiles.html">SplitTextFiles.pl</a>
|
|
163 </p>
|
|
164 <p>
|
|
165 </p>
|
|
166 <h2>COPYRIGHT</h2>
|
|
167 <p>Copyright (C) 2015 Manish Sud. All rights reserved.</p>
|
|
168 <p>This file is part of MayaChemTools.</p>
|
|
169 <p>MayaChemTools is free software; you can redistribute it and/or modify it under
|
|
170 the terms of the GNU Lesser General Public License as published by the Free
|
|
171 Software Foundation; either version 3 of the License, or (at your option)
|
|
172 any later version.</p>
|
|
173 <p> </p><p> </p><div class="DocNav">
|
|
174 <table width="100%" border=0 cellpadding=0 cellspacing=2>
|
|
175 <tr align="left" valign="top"><td width="33%" align="left"><a href="./MACCSKeysFingerprints.html" title="MACCSKeysFingerprints.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./MergeTextFilesWithSD.html" title="MergeTextFilesWithSD.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>MergeTextFiles.pl</strong></td></tr>
|
|
176 </table>
|
|
177 </div>
|
|
178 <br />
|
|
179 <center>
|
|
180 <img src="../../images/h2o2.png">
|
|
181 </center>
|
|
182 </body>
|
|
183 </html>
|