# How do i get CR+LF ('\\r\\n') line endings using CSV.jl?

**URL:** <https://discourse.julialang.org/t/how-do-i-get-cr-lf-r-n-line-endings-using-csv-jl/20676>\
**Category:** New to Julia\
**Created:** [February 11, 2019, 5:19pm UTC](https://discourse.julialang.org/t/how-do-i-get-cr-lf-r-n-line-endings-using-csv-jl/20676 "2019-02-11T17:19:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alujoe](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@alujoe](https://discourse.julialang.org/u/alujoe)\
**Post date:** [February 11, 2019, 5:19pm UTC](https://discourse.julialang.org/t/how-do-i-get-cr-lf-r-n-line-endings-using-csv-jl/20676/1 "2019-02-11T17:19:48Z")

</div>

Hi,  
I would like to write a DataFrame to a csv-file in DOS-style (‘\r\n’).  
Something like  
CSV.write(csv\_file, DataFrame, delim=‘;’)  
writes the usual ‘\n’ to the end of the line, but I need ‘\r\n’ line endings and couldn’t find a parameter to do it. How can I do it ?

Thank you for helping me.

---

<div class="post-metadata">

**Author:** ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Post date:** [February 12, 2019, 8:46am UTC](https://discourse.julialang.org/t/how-do-i-get-cr-lf-r-n-line-endings-using-csv-jl/20676/2 "2019-02-12T08:46:57Z")

</div>

This works (although it can probably be improved in various ways).  
The conversion to an Array{Any,2} might be superfluous.

```julia
using DataFrames
using DelimitedFiles 

x=["a" 1;"b" 2.3;"maha" 22]
df=DataFrame(A=String.(x[:,1]),B=Float64.(x[:,2]))

arr=convert(Array{Any,2},df)

fi="C:\\temp\\file2.csv"
isfile(fi)&&rm(fi)
fiostream=open(fi,"a+")

rows,cols=size(arr)
sep=','
for i=1:rows
    v=view(arr,i,:)
    for j=1:cols
        elm=string.(v[j])
        write(fiostream,elm)
        j<cols&&write(fiostream,sep)
    end    
    write(fiostream,"\r\n")
end

close(fiostream)

```

---

<div class="post-metadata">

**Author:** ![alujoe](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@alujoe](https://discourse.julialang.org/u/alujoe)\
**Post date:** [February 12, 2019, 11:30am UTC](https://discourse.julialang.org/t/how-do-i-get-cr-lf-r-n-line-endings-using-csv-jl/20676/3 "2019-02-12T11:30:38Z")

</div>

Hi bernhard,

thank you for your work around. In the meantime I found a pull request for this issue: [https://github.com/JuliaData/CSV.jl/pull/376](https://github.com/JuliaData/CSV.jl/pull/376)

Edit: Working with [unix2dos](https://sourceforge.net/projects/dos2unix/files/latest/download) works as well:  
cmd(x) = run(`cmd /C $x`)

cmd(“unix2dos.exe $myfile”) # unix2dos.exe is in Julia path
