Skip to content

Region Matching Fails with Trailing Spaces in CSV or GeoJSON #310

@atima

Description

@atima

The region matching logic fails when the region ID in the CSV and the corresponding ID in the GeoJSON include any trailing whitespace. This behavior suggests that a preprocessing step, such as whitespace trimming, is being applied to one dataset (either CSV or GeoJSON) but not both, causing the two strings to become mismatched before comparison.

In the provided example, the region ID is present in both files as "San Andres y Providencia  " (note the trailing space), yet the tool reports an error.

Steps to Reproduce

  1. Use the following data files:

    • GeoJSON: https://raw.githubusercontent.com/go-cart-io/cartogram-web/refs/heads/main/internal/static/cartdata/colombia/Input.json
    • CSV: https://raw.githubusercontent.com/go-cart-io/cartogram-web/refs/heads/main/internal/static/cartdata/colombia/data.csv
    • Note: Both files contain the ID "San Andres y Providencia  " with an identical trailing space.
  2. Run the command:

    cartogram-linux-amd64 Input.json data.csv --area "Population (people)"
  3. Observe the output (Error):

    ERROR: ID San Andres y Providencia in CSV is not in GeoJSON
    

Expected Behavior

The tool should successfully find a match because the strings are identical:

"San Andres y Providencia  " (from CSV) SHOULD MATCH "San Andres y Providencia  " (from GeoJSON).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions