toTsvStr

fun AnyFrame.toTsvStr(includeHeader: Boolean = INCLUDE_HEADER, delimiter: Char = TSV_DELIMITER, quote: Char? = QUOTE, quoteMode: QuoteMode = QUOTE_MODE, escapeChar: Char? = ESCAPE_CHAR, commentChar: Char? = COMMENT_CHAR, headerComments: List<String> = HEADER_COMMENTS, recordSeparator: String = RECORD_SEPARATOR): String

Convert DataFrame to TSV String

Converts this DataFrame to a TSV String.

Parameters you can use to customize the process include, for instance, delimiter, includeHeader, quoteMode, and headerComments. See the param list below for all settings.

The integration is built upon Apache Commons CSV.

Similar Functions

With overloads of DataFrame.writeTsv(), you can write TSV to File, Path, Appendable, or String.

For example, DataFrame.writeTsv("output.tsv")

or DataFrame.writeTsv(File("output.tsv"), quoteMode = QuoteMode.ALL)

Converting to a String can be done like this:

DataFrame.toTsvStr(delimiter = ",")

Parameters

delimiter

The field delimiter character. Default: '\t'.

Ignored if hasFixedWidthColumns is true.

includeHeader

Whether to include the header in the output. Default: true.

quote

The quote character. Default: ".

Used when field- or line delimiters should be interpreted as literal text.

For example: 123,"hello, there",456, would correspond to: 123; hello, there; 456.

quoteMode

The QuoteMode to use when writing CSV / TSV files. Default: QuoteMode.MINIMAL.

escapeChar

The escape character to use when writing CSV / TSV files with QuoteMode.NONE. Default: null. This will double-quote the value.

commentChar

The character that indicates a comment line in a CSV / TSV file. Default: '#'.

headerComments

A list of comments to include at the beginning of the CSV / TSV file. Default: empty list.

recordSeparator

The character that separates records in a CSV / TSV file. Default: '\n', a Unix-newline.