//> using dep io.github.quafadas::scautable:0.0.23
In console
In scripts or conosle, fansi formatting is strongly preferred.
import io.github.quafadas.table.*
def csv = CSV.resource("simple.csv")
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|
// +-+----+----+----+
// |0| 1| 2| 7|
// |1| 3| 4| 8|
// |2| 5| 6| 9|
// +-+----+----+----+"""
// but this is easier to type and is fansi;
csv.toSeq.ptbln
// |[32m [39m|[97mcol1[39m|[31mcol2[39m|[34mcol3[39m|
// +-+----+----+----+
// |[32m0[39m|[97m 1[39m|[31m 2[39m|[34m 7[39m|
// |[32m1[39m|[97m 3[39m|[31m 4[39m|[34m 8[39m|
// |[32m2[39m|[97m 5[39m|[31m 6[39m|[34m 9[39m|
// +-+----+----+----+
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
And your case classes are now easily visible and searchable.
Scala JS
I love scala JS, so it cross compiles, and gives you back a scalatags table. This is of questionable usefulness, but it's fun.
TODO : Laminar integration, which nobody wants but would be cool.
In this article