You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I want to write CSV file row by row, I should wrap each row with 1-element vector (Table-compatible source) and pass into CSV.write function. Maybe there can be a simpler version of CSV.writerow function, that can take any "row-compatible" object, like struct, tuple, named tuple, and so on?
It can be needed to write CSV-formatted logs, like in this MWE:
using CSV
using HTTP
using MsgPack
struct MyMsg
name::String
index::Int
number::Float64end
MsgPack.msgpack_type(::Type{MyMsg}) = MsgPack.StructType()
@async HTTP.WebSockets.listen("127.0.0.1", UInt16(1234)) do ws
append =falsewhile!eof(ws) # even with this line there is `EOFError: read end of file``
bytes =readavailable(ws)
msg =unpack(bytes, MyMsg)
println(msg)
#I want to save msg line-by-line into CSV without storing it into a vector of total number of messages
CSV.write("test2.csv", [msg];, delim ='\t', append = append)
append =trueendend
HTTP.WebSockets.open("ws://127.0.0.1:1234/"; binary=true) do ws
for k =1:10
msg =MyMsg("hello", k, randn())
write(ws, pack(msg))
endend
The text was updated successfully, but these errors were encountered:
Implements #1001. We already had the internal methods here, so this PR just adds some higher-level user-facing methods that take a plain "row" (from the Tables.jl "Row" interface) or an `io` and row. This is convenient when you don't have a traditional iterator (and can use RowWriter), but just want to repeatedly call `CSV.writerow` yourself and get the delimited output.
Implements #1001. We already had the internal methods here, so this PR just adds some higher-level user-facing methods that take a plain "row" (from the Tables.jl "Row" interface) or an `io` and row. This is convenient when you don't have a traditional iterator (and can use RowWriter), but just want to repeatedly call `CSV.writerow` yourself and get the delimited output.
If I want to write CSV file row by row, I should wrap each row with 1-element vector (Table-compatible source) and pass into
CSV.write
function. Maybe there can be a simpler version ofCSV.writerow
function, that can take any "row-compatible" object, like struct, tuple, named tuple, and so on?It can be needed to write CSV-formatted logs, like in this MWE:
The text was updated successfully, but these errors were encountered: