Skip to content

Parse quoted multiline CSV records correctly in QuPath tables and point annotations #17

Closed

Description

@guijacquemet

Failure mechanism

The shared Toolkit writes table/points outputs as real UTF-8 CSV, allowing commas, escaped quotes and line breaks inside quoted cells (see Toolkit protocol). QuPath instead parses results by readLines('UTF-8') and then calls a one-line splitCsv function:

A CSV record containing a quoted newline becomes two or more rows. A property in the points output containing a newline can shift the apparent rows: coordinate fields on continuation lines may be absent, malformed or interpreted as separate points. Tables can show incorrect row counts and distorted measurements without a worker-side error.

Reproduction data

Use a CSV table with header y,x,note and one row 1,2,"first line\nsecond line" (actual newline inside the quoted field). The Toolkit serializes this as one CSV record. QuPath's readLines supplies two physical lines and splitCsv cannot recombine them.

Also test quoted commas and doubled quotes (which splitCsv partially handles), UTF-8 and empty cells.

Recommended fix

Use an RFC 4180-aware CSV record reader rather than readLines and a custom line splitter. Keep the existing visible row limit for tables, but count logical CSV records. Parse points with the same reader and validate coordinate columns before creating annotations.

Acceptance criteria

  • A quoted multiline cell remains one table row, with its full text.
  • A points record with multiline metadata creates exactly one point with the expected coordinates.
  • Quoted commas, doubled quotes, non-ASCII values and empty cells roundtrip.
  • Malformed CSV produces an actionable display error rather than misplaced annotations.

Priority: P2 — incorrectly presented tabular scientific data and points. Source-traced against the Toolkit CSV contract; no QuPath GUI run performed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions