mountainMath / mountainMath/cansim

Special characters in column names

Open
#169 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
51
Forks
6
Avg merge
15h 34m
Merged PRs (30d)
1

Description

StatCan API returns column names with non-standard characters that make working with data difficult. These characters include em-dash, closing quotation %E2%80%99 instead of apostrophe, carriage return %0A, and most importantly, non-breaking whitespace %C2%A0. In partular that last one causes problems because it gets translated to regular white space in the console and can't be accessed via copy-paste, making that column inaccessible in an R session.

The package should repair the non-breaking whitespace under the hood and emit a warning to let users know that the StatCan data was modified and why. This repair should happen on first parse from the CSV or from vector or coordinate data calls as well as in metadata calls and before caching the data in a local database.

Code to systematically find non-standard characters

whitelist <- "[a-zA-Z0-9 àâäèéêëîïôœùûüÿçÀÂÄÈÉÊËÎÏÔŒÙÛÜŸÇ,\\.:\\(\\)=\\/'\"\\&\\#;-\\+-_]"

d <- list_cansim_cubes()
non_standard_whitespace="%C2%A0"
right_single_quote="%E2%80%99"
line_feed = "%0A"
en_dash="%E2%80%93"
d |> 
  mutate(special_character=gsub(whitelist,"",dimensionNameEn),.before="cubeTitleEn") |>
  mutate(url_encoded=URLencode(special_character),.before="special_character") |>
  filter(nchar(special_character) >0) |>
  select(cansim_table_number,url_encoded,special_character,dimensionNameEn) |>
  filter(url_encoded!=en_dash)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with list_cansim_cubes() and trace the first parse paths for CSV, vector or coordinate calls, and metadata calls, then inspect the local-database caching boundary. Use the supplied character-detection code to identify affected names. Done means non-breaking whitespace is repaired, users receive a warning explaining the modification, and the repaired data is cached consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.