Does this do what you want?
julia> using CSV
julia> using DataFrames
julia> df = DataFrame(a=1:2, b=3:4)
2×2 DataFrame
Row │ a b
│ Int64 Int64
─────┼──────────────
1 │ 1 3
2 │ 2 4
julia> sprint(CSV.write, df)
"a,b\n1,3\n2,4\n"