Skip to content

Filter out single and double quotes from CSV #66

Closed

Description

@mfhepp

Sometimes, it is unavoidable that CSV files contain single or double quotes for string values.

Pantable seems to include them in the resulting tables, which does not look very nice:

prefix, city_or_region, comments, Status
'030', 'Berlin', 'My comment', True
'069', 'Frankfurt', , False
'089', 'Munich', 'Another comment', True

Screen Shot 2022-03-13 at 22 54 49

It would be nice to be able to tell Pantable to remove single and double quotes from field values.

Activity

  1. alerque commented on Mar 15, 2022

    @alerque
    Contributor

    I don't think those are necessarily even valid CSV files, mixing single quotes and no quoting in a single file is just ... bogus. The spec only allows for double quotes. I'm not saying those things (and other problems such as tab/space or use of things other than commas for delimiters do happen in the wild. I just suggest you normalize your CSV data using other more robust tooling (I recommend csvkit tools) first thing after receiving it before you hand it off to other tools like this one that assume properly-formed data. All downstream tools should not be responsible for parsing all the possible broken formats that might exist in the wild.

  2. added a commit that references this issue on Oct 6, 2026
    62b7069
  3. ickc commented on Oct 6, 2026

    @ickc
    Owner

    This is already possible with csv-kwargs, which is passed to Python's csv.reader:

    ```table
    ---
    csv-kwargs:
      quotechar: "'"
      skipinitialspace: true
    ---
    prefix, city_or_region, comments, Status
    '030', 'Berlin', 'My comment', True
    '069', 'Frankfurt', , False
    ```

    quotechar makes single quotes the quoting character, and skipinitialspace drops the space after each comma so the quotes are recognised. Documented in 62b7069 (#71), on the Including a CSV file page. This closes when #71 is merged.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions