Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-8377

CSVReader: quoting and trimming with value separator inconsistency

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      There is a little inconsistency of quoting and trimming when the value separator is present in the data and using Apache Common CSV parser.

      Example:

      case, A, B
      quoted value,"aa",
      quoted and trimmed value, "aa" ,
      quoted value with comma,"a,a",
      trimmed but wrongly unquoted value with comma, "a,a" ,

      here in the 3 first cases, the value is correctly parsed

      A : "aa", B : null
      A : "aa", B : null
      A : "a,a", B : null

      so using separately quoting containing the value separator or spaces to trim works well.
       
      However in the last example that combine quoted value separator and outer spaces to trim, then quoting fails

      A : "\"a", B : "a\""

       
      I think setting org.apache.commons.csv.CSVFormat.withIgnoreSurroundingSpaces(true) on the CSV parser would solve the issue, but I don't see the whole picture to tell if this would have other side effects.

      Attachments

        Activity

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

          People

            Unassigned Unassigned
            Kasonnara Kasonnara

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 40m
                1h 40m

                Slack

                  Issue deployment