Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/FSharp.Data.Csv.Core/CsvRuntime.fs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ type CsvFile<'RowType>

use writer = writer

// RFC 4180 (https://www.rfc-editor.org/rfc/rfc4180)
// 2. Definition of the CSV Format
// Each record is located on a separated line, delimited by a line break CRLF
writer.NewLine <- "\r\n"

let nullSafeguard str =
match str with
| null -> String.Empty
Expand Down
5 changes: 3 additions & 2 deletions tests/FSharp.Data.Tests/CsvProvider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ let ``Can create type for small document``() =

[<Test>]
let ``CsvFile.Rows is re-entrant if the underlying stream is``() =
let csv = CsvFile.Load(Path.Combine(__SOURCE_DIRECTORY__, "Data/SmallTest.csv"))
let csv = CsvFile.Load(Path.Combine(__SOURCE_DIRECTORY__, "Data/SmallTest.csv"))
let twice = [ yield! csv.Rows; yield! csv.Rows ]
twice |> Seq.length |> should equal 6

Expand Down Expand Up @@ -465,7 +465,8 @@ let ``Parse single row with trailing newline``() =
let ``Parse two rows``() =
let rows = SimpleWithStrCsv.ParseRows("false,abc, 31\ntrue, def, 42")
rows.Length |> should equal 2
(new SimpleWithStrCsv(rows)).SaveToString() |> should equal ("Column1,ColumnB,Column3" + Environment.NewLine + "false,abc,31" + Environment.NewLine + "true, def,42" + Environment.NewLine)
(new SimpleWithStrCsv(rows)).SaveToString() |> should equal ("Column1,ColumnB,Column3" + "\r\n" + "false,abc,31" + "\r\n" + "true, def,42" + "\r\n")
// (new SimpleWithStrCsv(rows)).SaveToString() |> should equal ("Column1,ColumnB,Column3" + Environment.NewLine + "false,abc,31" + Environment.NewLine + "true, def,42" + Environment.NewLine)

let [<Literal>] csvWithDataEndingWithSeparator = """
Name|Company |Email|Password
Expand Down