csv2tsv

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

void
csv2tsv
(
InputSource
OutputRange
)
(
InputSource inputSource
,
auto ref OutputRange outputStream
,
ubyte[] readBuffer
,
string filename = "(none)"
,
size_t skipLines = 0
,
const char csvQuote = '"'
,
const char csvDelim = ','
,
const char tsvDelim = '\t'
,
const string tsvDelimReplacement = " "
,
const string tsvNewlineReplacement = " "
,
bool discardBOM = true
)
if (
isBufferableInputSource!InputSource &&
isOutputRange!(OutputRange, char)
)

Parameters

inputSource InputSource

A "bufferable" input source, either a file open for read or an input range with ubyte elements.

outputStream OutputRange

An output range to write TSV bytes to.

readBuffer ubyte[]

A buffer to use for reading.

filename string

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

skipLines size_t

Number of lines to skip before outputting records. Typically used to skip writing header lines.

csvQuote char

The quoting character used in the CSV input.

csvDelim char

The field delimiter character used in the CSV input.

tsvDelim char

The field delimiter character to use in the TSV output.

tsvDelimReplacement string

String to use when replacing TSV field delimiters (e.g. TABs) found in the CSV data fields.

tsvNewlineReplacement string

String to use when replacing newlines found in the CSV data fields.

discardBOM bool

If true (the default), a UTF-8 Byte Order Mark found at the start of the input stream will be dropped.

Throws

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

Meta