spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From HyukjinKwon <...@git.apache.org>
Subject [GitHub] spark pull request #16976: [SPARK-19610][SQL] Support parsing multiline CSV ...
Date Thu, 23 Feb 2017 08:44:45 GMT
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16976#discussion_r102663212
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala
---
    @@ -233,3 +236,31 @@ private[csv] class UnivocityParser(
         }
       }
     }
    +
    +private[csv] object UnivocityParser {
    +  def tokenizeStream(
    +      inputStream: InputStream,
    +      header: Boolean,
    +      settings: CsvParserSettings): Iterator[Array[String]] = new Iterator[Array[String]]
{
    +    private val parser = new CsvParser(settings)
    +    // Note that, here we assume `inputStream` is the whole file that might include the
header.
    +    parser.beginParsing(inputStream)
    +    private var nextRecord = {
    +      if (header) {
    +        parser.parseNext()
    --- End diff --
    
    Yup, existing code path processes line by line so comments and empty lines had to manually
skipped because it threw an error if each line has only commented line or empty. This is nicely
handled in Univocity and the initial version of CSV actually did this in this way.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message