diff --git a/REQUIRE b/REQUIRE index 0e443c7..9c392ba 100644 --- a/REQUIRE +++ b/REQUIRE @@ -7,3 +7,4 @@ DataValues 0.1.0 FileIO 0.9.0 HTTP 0.6.0 IterableTables 0.6.1 +TableShowUtils 0.0.1 diff --git a/src/CSVFiles.jl b/src/CSVFiles.jl index cd3cac6..2415909 100644 --- a/src/CSVFiles.jl +++ b/src/CSVFiles.jl @@ -1,7 +1,7 @@ module CSVFiles using TextParse, IteratorInterfaceExtensions, TableTraits, TableTraitsUtils, - DataValues, FileIO, HTTP + DataValues, FileIO, HTTP, TableShowUtils import IterableTables export load, save @@ -18,6 +18,26 @@ struct CSVStream keywords end +function Base.show(io::IO, source::CSVFile) + TableShowUtils.printtable(io, getiterator(source), "CSV file") +end + +function Base.show(io::IO, ::MIME"text/html", source::CSVFile) + TableShowUtils.printHTMLtable(io, getiterator(source)) +end + +Base.Multimedia.mimewritable(::MIME"text/html", source::CSVFile) = true + +function Base.show(io::IO, source::CSVStream) + TableShowUtils.printtable(io, getiterator(source), "CSV file") +end + +function Base.show(io::IO, ::MIME"text/html", source::CSVStream) + TableShowUtils.printHTMLtable(io, getiterator(source)) +end + +Base.Multimedia.mimewritable(::MIME"text/html", source::CSVStream) = true + function fileio_load(f::FileIO.File{FileIO.format"CSV"}, delim=','; args...) return CSVFile(f.filename, delim, args) end