API
ClipData.cliptable
— Functioncliptable(; kwargs...)
Make a table from the clipboard. Returns a CSV.File
, which can then be transformed into a DataFrame
or other Tables.jl-compatible object.
cliptable
auto-detects delimiters, and all keyword arguments are passed directly to the CSV.File
constructor.
Examples
julia> # Send string to the clipboard
"""
a, b
1, 2
100, 200
""" |> clipboard
julia> cliptable()
2-element CSV.File{false}:
CSV.Row: (a = 1, b = 2)
CSV.Row: (a = 100, b = 200)
cliptable(t; delim = ' ', kwargs...)
Send a Tables.jl-compatible object to the clipboard. Default delimiter is tab. Accepts all keyword arguments that can be pased to CSV.write
.
Example
julia> t = (a = [1, 2, 3], b = [100, 200, 300])
(a = [1, 2, 3], b = [100, 200, 300])
julia> cliptable(t)
a b
1 100
2 200
3 300
ClipData.cliparray
— Functioncliparray(; kwargs...)
Make a Vector
or Matrix
from the clipboard. Auto-detects delimiters, and all keyword arguments are passed directly to a CSV.File
constructor. If the returned CSV.File
has one column, cliparray
returns a Vector
. Otherwise, it returns a Matrix
.
Examples
julia> # Send string to clipboard
"""
1 2
3 4
""" |> clipboard
julia> cliparray()
2×2 Matrix{Int64}:
1 2
3 4
julia> """
1
2
3
4
""" |> clipboard
julia> cliparray()
4-element Vector{Int64}:
1
2
3
4
cliparray(t::AbstractVecOrMat; kwargs...)
Send a Vector
or Matrix
to the clipboard. Default delimiter is tab and with no header. Accepts all keyword arguments that can be passed to CSV.write
.
Examples
julia> """
1 2
3 4
""" |> clipboard
julia> cliparray()
2×2 Matrix{Int64}:
1 2
3 4
ClipData.mwetable
— Functionmwetable([io::IO=stdout]; name="df")
Create a Minimum Working Example (MWE) using the clipboard. tablmwe
prints out a multi-line comma-separated string and provides the necessary code to read that string using CSV.File
. The object is assigned the name given by name
(default "df"
). Prints to io
, which is by default stdout
.
Examples
julia> """
a b
1 2
100 200
""" |> clipboard
julia> mwetable()
df = """
a,b
1,2
100,200
""" |> IOBuffer |> CSV.File
mwetable([io::IO=stdout], t; name="df")
Create a Minimum Working Example (MWE) from an existing Tables.jl-compatible object. tablmwe
prints out a multi-line comma-separated string and provides the necessary code to read that string using CSV.File
. The object is assigned the name given by name
(default :df
). Prints to io
, which is by default stdout
.
Examples
julia> t = (a = [1, 2, 3], b = [100, 200, 300])
(a = [1, 2, 3], b = [100, 200, 300])
julia> mwetable(t)
df = """
a,b
1,100
2,200
3,300
""" |> IOBuffer |> CSV.File
ClipData.mwearray
— Functionmwearray([io::IO=stdout]; name=:X)
Create a Minimum Working Example (MWE) from the clipboard to create an array. mwearray
returns the a multi-line string with the code necessary to read the string stored in clipboard as a Vector
or Matrix
. Prints to io
, which is by default stdout
.
Examples
julia> """
1 2
3 4
""" |> clipboard
julia> mwearray()
X = """
1,2
3,4
""" |> IOBuffer |> CSV.File |> Tables.matrix
mwearray([io::IO=stdout], t::AbstractMatrix; name=:X)
Create a Minimum Working Example (MWE) from a Matrix
. mwearray
returns the a multi-line string with the code necessary to recreate t
. Prints to io
, which is by default stdout
.
Examples
julia> X = [1 2; 3 4]
2×2 Matrix{Int64}:
1 2
3 4
julia> mwearray(X)
X = """
1,2
3,4
""" |> IOBuffer |> CSV.File |> Tables.matrix
mwearray([io::IO=stdout], t::AbstractVector; name=:x)
Create a Minimum Working Example (MWE) from a Vector
. mwearray
returns the a multi-line string with the code necessary to recreate t
. Prints to io
, which is by default stdout
.
Example
julia> mwearray(x; name=:x)
x = """
1
2
3
4
""" |> IOBuffer |> CSV.File |> Tables.matrix |> vec
ClipData.@mwetable
— Macro@mwetable(t)
Create a Minimum Working Example (MWE) from an existing Tables.jl-compatible object. tablmwe
prints out a multi-line comma-separated string and provides the necessary code to read that string using CSV.File
. The name assigned to the object in the MWE is the same as the name of the input object. Prints to stdout
.
Examples
julia> my_special_table = (a = [1, 2, 3], b = [100, 200, 300])
(a = [1, 2, 3], b = [100, 200, 300])
julia> @mwetable my_special_table
my_special_table = """
a,b
1,100
2,200
3,300
""" |> IOBuffer |> CSV.File
ClipData.@mwearray
— Macro@mwearray(t)
Create a Minimum Working Example (MWE) from a Vector
or Matrix
with the same name as the object in the Julia session. Prints to stdout
.
Examples
julia> my_special_matrix = [1 2; 3 4]
2×2 Matrix{Int64}:
1 2
3 4
julia> @mwearray my_special_matrix
my_special_matrix = """
1,2
3,4
""" |> IOBuffer |> CSV.File |> Tables.matrix