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
A user has uploaded a CSV which uses solely carriage return (CR, or \r) characters for their newlines. The current SourceLineReader.readLineWithTerminator handles this by successfully reading in the header row and then discarding the rest. We want it to display every row in the CSV.
We run something like this:
// get a blob from Google Cloud Platform storagevalspreadsheetSource=Source.fromInputStream(Channels.newInputStream(blob.reader()))
valreader=CsvReader.open(spreadsheetSource)
vallines= reader.all()
// lines: List[List[String]] = List(List("First Name", " Last Name", " email"))
This is despite the fact that the file we're reading from has five lines. I have also tried this with Source.fromFile, and there's no difference.
I created the file from a normal CSV with LF-style line endings, and then ran this bash command:
$ tr '\n''\r'< fnln.csv >fnln.cr.csv
Side note: why can't we use Source's built-in getLines function? Is there a reason that we need the line terminator in each string?
The text was updated successfully, but these errors were encountered:
The current implementation of scala-csv expects \n and \r\n as a newline code and does not support \r.
This was simply because I had never encountered a system that treated ' \r' as a newline code, and I thought it was enough. But I should probably support it.
Side note: why can't we use Source's built-in getLines function? Is there a reason that we need the line terminator in each string?
The difference between SourceLineReader.readLineWithTerminator and Source#getLines is whether it gets rid of newline codes or not.
To parse a csv field that contains multiline text, I need to preserve newline codes. Source#getLines doesn't fit this case.
A user has uploaded a CSV which uses solely carriage return (CR, or
\r
) characters for their newlines. The currentSourceLineReader.readLineWithTerminator
handles this by successfully reading in the header row and then discarding the rest. We want it to display every row in the CSV.We run something like this:
This is despite the fact that the file we're reading from has five lines. I have also tried this with
Source.fromFile
, and there's no difference.I created the file from a normal CSV with
LF
-style line endings, and then ran this bash command:Side note: why can't we use
Source
's built-ingetLines
function? Is there a reason that we need the line terminator in each string?The text was updated successfully, but these errors were encountered: