Uploaded image for project: 'Commons CSV'
  1. Commons CSV
  2. CSV-41

CSV Parser loops inifinitely if last line starts with a comment char

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • 1.0
    • Parser
    • None

    Description

      Behaviour:

      Whenever the last non-empty line of the CSV file starts with a comment, the CSVParser loops infinitely!

      Examplary CSV file:

      some
      # comment OK
      line
      # comment OK
      value
      # problematic comment
      

      Excerpt of Java code:

         private static final char COMMENT = '#';
         private static final char QUOTE = '"';
         private static final char SEPARATOR = ';';
      
         CSVStrategy csvStrategy = new CSVStrategy(SEPARATOR, QUOTE, COMMENT);
         CSVParser parser = new CSVParser(reader, csvStrategy);
      
         String[] line = parser.getLine();
      
         while (line != null) {
            Log.debug("Line: " + line[0]);
            // Do something
            line = parser.getLine();
         }
      

      Used Maven Dependency:

       <dependency>
          <groupId>org.apache.solr</groupId>
          <artifactId>solr-commons-csv</artifactId>
          <version>1.4.0</version>
       </dependency>
      

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            edgarphilipp Edgar Philipp
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment