JuliaData / JuliaData/CSV.jl

Prettier (or custom) `normalizenames` behaviour?

Open
#993 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

improvement
Dominant language
Julia
Stars
506
Forks
150
Avg merge
4d 16h
Merged PRs (30d)
7

Description

(originally posted in #990)

the results [of normalizenames] are sometimes unexpected like “Profit (net)“ turning into "Profit_net_" with a trailing underscore

I agree that this normalization results in something ugly, and i'd been meaning to open an issue about it for ages.

I see this column naming pattern in quite a lot of data, e.g. with "Quanitity (unit)" like "Weight (kg)". It'd be nice to normalize these column names to valid identifiers so we can use getproperty syntax like file.Weight_kg but without also making the names a bit prettier / more intuitive for users e.g. Weight_kg not Weight_kg_.

One option would be to change the CSV.normalizename function... e.g. just strip trailing _ (which is what we map anything that's not Base.is_id_char to). I suppose this would be breaking. It'd also mean more names would map to the same thing, but i'm not sure that's an issue in reality.

Another option could be allowing users to pass normalizenames = my_func with signature my_func(::String) -> Symbol

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 by reading the CSV.normalizename function and the normalizenames option, then examine how names such as "Profit (net)" and "Weight (kg)" are transformed for getproperty access. Done requires a decided approach to trailing underscores or user-supplied normalizenames functions, including the compatibility tradeoff described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.