Displaying Tables

In console

In scripts or conosle, fansi formatting is strongly preferred.

import io.github.quafadas.table.*

def csv = CSV.fromString("col1,col2,col3\n1,2,7\n3,4,8\n5,6,9")
csv.toSeq.consoleFormatNt(fansi = false)
// res0: String = """| |col1|col2|col3|
// |-|----|----|----|
// |0|   1|   2|   7|
// |1|   3|   4|   8|
// |2|   5|   6|   9|
// |-|----|----|----|"""

// This  much better in a console / script, but ugly in browser
csv.toSeq.consoleFormatNt(fansi = true)
// res1: String = """+------+------+------+
// | col1 | col2 | col3 |
// +------+------+------+
// | 1    | 2    | 7    |
// | 3    | 4    | 8    |
// | 5    | 6    | 9    |
// +------+------+------+"""

// but this is easier to type and is fansi;
csv.toSeq.ptbln
// +------+------+------+
// | col1 | col2 | col3 |
// +------+------+------+
// | 1    | 2    | 7    |
// | 3    | 4    | 8    |
// | 5    | 6    | 9    |
// +------+------+------+

In browser (currently untested with named tuples)

import io.github.quafadas.table.*

case class ScauTest(anInt: Int, aString: String)

val table = Seq(ScauTest(1, "one"), ScauTest(2, "two"), ScauTest(3, "booyakashaha!"))

println(table.consoleFormat(fancy = false))

On the JVM in particular, the ability to pop it open in the browser, see and search the actual data... can be useful. Particularly if you're working with a lot of messy, csv data for example.

import io.github.quafadas.table.*

case class ScauTest(anInt: Int, aString: String)
val soComplex = Seq(ScauTest(1, "one"), ScauTest(2, "two"))

scautable.desktopShow(soComplex)

Will pop open a browser... using https://datatables.net desktop

And your case classes are now easily visible and searchable.