Skip to content

Commit

Permalink
Merge pull request #23 from davidanthoff/tableshowutils
Browse files Browse the repository at this point in the history
Use TableShowUtils.jl
  • Loading branch information
davidanthoff authored May 30, 2018
2 parents ba090be + 0d2920f commit 322b043
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ DataValues 0.1.0
FileIO 0.9.0
HTTP 0.6.0
IterableTables 0.6.1
TableShowUtils 0.0.1
22 changes: 21 additions & 1 deletion src/CSVFiles.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module CSVFiles

using TextParse, IteratorInterfaceExtensions, TableTraits, TableTraitsUtils,
DataValues, FileIO, HTTP
DataValues, FileIO, HTTP, TableShowUtils
import IterableTables

export load, save
Expand All @@ -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
Expand Down

0 comments on commit 322b043

Please sign in to comment.