MergeTextFiles.pl - Merge multiple CSV or TSV text files into a single text file
MergeTextFiles.pl [-h, --help] [--indelim comma | semicolon] [-c, --columns colnum,...;... | collabel,...;...] [-k, --keys colnum,...;... | collabel,...;...] [-m, --mode colnum | collabel] [-o, --overwrite] [--outdelim comma | tab | semicolon] [-q, --quote yes | no] [-r, --root rootname] [-s, --startcol colnum | collabel] [--startcolmode before | after] [-w, --workingdir dirname] TextFiles...
Merge multiple CSV or TSV TextFiles into first TextFile to generate a single text file. Unless -k --keys option is used, data rows from other TextFiles are added to first TextFile in a sequential order, and the number of rows in first TextFile is used to determine how many rows of data are added from other TextFiles.
Multiple TextFiles names are separated by space. The valid file extensions are .csv and .tsv for comma/semicolon and tab delimited text files respectively. All other file names are ignored. All the text files in a current directory can be specified by *.csv, *.tsv, or the current directory name. The --indelim option determines the format of TextFiles. Any file which doesn't correspond to the format indicated by --indelim option is ignored.
Print this help message.
Input delimiter for CSV TextFile(s). Possible values: comma or semicolon. Default value: comma. For TSV files, this option is ignored and tab is used as a delimiter.
This value is mode specific. It is a list of columns to merge into first text file specified by column numbers or labels for each text file delimited by ";". All specified text files are merged into first text file.
Default value: all;all;.... By default, all columns from specified text files are merged into first text file.
For colnum mode, input value format is: colnum,...;colnum,...;.... Example:
For collabel mode, input value format is: collabel,...;collabel,...;.... Example:
This value is mode specific. It specifies column keys to use for merging all specified text files into first text file. The column keys are specified by column numbers or labels for each text file delimited by ";".
By default, data rows from text files are merged into first file in the order they appear.
For colnum mode, input value format is:colkeynum, colkeynum;.... Example:
For collabel mode, input value format is:colkeylabel, colkeylabel;.... Example:
Specify how to merge text files: using column numbers or column labels. Possible values: colnum or collabel. Default value: colnum.
Overwrite existing files.
Output text file delimiter. Possible values: comma, tab, or semicolon Default value: comma.
Put quotes around column values in output text file. Possible values: yes or no. Default value: yes.
New text file name is generated using the root: <Root>.<Ext>. Default file name: <FirstTextFileName>1To<Count>Merged.<Ext>. The csv, and tsv <Ext> values are used for comma/semicolon, and tab delimited text files respectively.
This value is mode specific. It specifies the column in first text file which is used for start merging other text files.For colnum mode, specify column number and for collabel mode, specify column label.
Default value: last. Start merge after the last column.
Start the merge before or after the -s, --startcol value. Possible values: before or after Default value: after.
Location of working directory. Default: current directory.
To merge Sample2.csv and Sample3.csv into Sample1.csv and generate NewSample.csv, type:
To merge all Sample*.tsv and generate NewSample.tsv file, type:
To merge column numbers "1,2" and "3,4,5" from Sample2.csv and Sample3.csv into Sample1.csv starting before column number 3 in Sample1.csv and to generate NewSample.csv without quoting column data, type:
To merge column "Mol_ID,Formula,MolWeight" and "Mol_ID,NAME,ChemBankID" from Sample2.csv and Sample3.csv into Sample1.csv using "Mol_ID" as a column keys starting after the last column and to generate NewSample.tsv, type:
JoinTextFiles.pl, MergeTextFilesWithSD.pl, ModifyTextFilesFormat.pl, SplitTextFiles.pl
Copyright (C) 2021 Manish Sud. All rights reserved.
This file is part of MayaChemTools.
MayaChemTools is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.