The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

csv2tsv

VERSION

0.55 (2018-07-09 Mon)

SYNOPSIS

csv2tsv [-t str] [-n str] [-v] [-Q] [-2] [-~] file

DESCRIPTION

Transforms CSV formatted data (cf. RFC4180) into TSV formated data. Input is assumed to be UTF-8. (The input line ends can be both CRLF or LF. The output line ends are LF.) Warnings/errors would be properly printed on STDERR (as far as the author of this program experienced).

EXAMPLE

csv2tsv file.csv > file.tsv

csv2tsv -n '[\n]' file.csv > file.tsv # "\n" in the CSV cell will be transfomed to [\n].

csv2tsv -t TAB file.csv > file.tsv # "\t" in the CSV cell will be transfomed to "TAB". UTF-8 characters can be specified.

for i in *.csv ; do csv2tsv -n'"\n"' -t'"\t"' $i > ${i/csv/tsv} ; done # BASH or ZSH is required to use this "for" statement. Useful for multiple CSV files.

For the safety, when '-t' or '-n' is set with string character specification, a warning is displayed every time a values in the input cells matches the specified string charatcter unless -Q is set.

csv2tsv < file.csv > file.tsv # file name information cannot be passed to "csv2tsv". So the warning messages may lack a few information.

OPTION

-e str

Escape character(s) to be used to attach previous to the string matched to the string specified by -t or -n.

-t str

What the input TAB character will be replaced with is specified.

-n str

What "\n" character in the input CSV cell will be replaced with is specified.

-s char

Set CSV field separator anything different from ",".

-v

Always tell the existence of "\t" or "\n" even if "-t str" or "-n str" is specified.

-Q

No warning even if "\t" or "\n" is included in the cell of input.

-2

Double space output, to find "\n" anormality by human eyes. (For a kind expediency when this program author was firstly making this program)

-~

The opposite conversion of csv2tsv, i.e. TSV to CSV conversion. TABs and LINEENDs will be recovered if the intput was generated by this program "csv2tsv" with the same specification of "-t", "-n" and "-e".

-a

Always enclose all the fields by the double quotations when transforming TSV to CSV.

--help

Shows this help.

--help ja

Shows Japanese help.

--version

Shows the version information of this program.

AUTHOR

Toshiyuki Shimono bin4tsv@gmail.com

HISTORY

 2015-09-28 : Firstly created on a whim.    
 2016-07-06 : Some options are added such as -2.    
 2016-08-03 : Response to tab and enter characgers.     
 2018-06-24 : Once realeased on CPAN for the sake of Table::Hack.    
 2018-07-04 : Refinements to options. English manual is added. 
 2018-07-09 : -s and -a is added. Enabled to show the error input by Text::CSV_XS.

LICENSE AND COPYRIGHT

Copyright 2018 "Toshiyuki Shimono".

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.