csv2tsv

Read CSV from an input source, covert to TSV and write to an output source.

void
csv2tsv
(
InputRange
OutputRange
)
(
auto ref InputRange inputStream
,
auto ref OutputRange outputStream
,
string filename = "(none)"
,
size_t currFileLineNumber = 0
,
const char csvQuote = '"'
,
const char csvDelim = ','
,
const char tsvDelim = '\t'
,
string tsvDelimReplacement = " "
,
NullableSizeT maxRecords = NullableSizeT.init
)
if (
isInputRange!InputRange &&
isOutputRange!(OutputRange, char)
&&
is(Unqual!(ElementType!InputRange) == ubyte)
)

Parameters

InputRange

A ubyte input range to read CSV text from. A ubyte range matched byChunck. It also avoids convesion to dchar by front().

OutputRange

An output range to write TSV text to.

filename
Type: string

Name of file to use when reporting errors. A descriptive name = can be used in lieu of a file name.

currFileLineNumber
Type: size_t

First line being processed. Used when reporting errors. Needed only when part of the input has already been processed.

csvQuote
Type: char

The quoting character used in the input CSV file.

csvDelim
Type: char

The field delimiter character used in the input CSV file.

tsvDelim
Type: char

The field delimiter character to use in the generated TSV file.

tsvDelimReplacement
Type: string

A string to use when replacing newlines and TSV field delimiters occurring in CSV fields.

maxRecords

The maximum number of records to process (output lines). This is intended to support processing the header line separately.

Throws

Exception on finding inconsistent CSV. Exception text includes the filename and line number where the error was identified.

Meta