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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to