Skip to content

WISH: Allow for reserved symbols in variable names #16

@HenrikBengtsson

Description

@HenrikBengtsson

Issue

We can do:

> dirdf::dirdf_parse("foo,tag=100.rds", template = "name,~tag~=binsize.rds")
  name binsize rds        pathname
1  foo     100 rds foo,tag=100.rds

But we cannot get results with columns containing reserved symbols, e.g. we cannot return a bin_size column:

> dirdf::dirdf_parse("foo,tag=100.rds", template = "name,~tag~=bin_size.rds")
Error in dirdf::dirdf_parse("foo,tag=100.rds", template = "name,~tag~=bin_size.rds") : 
  Unexpected path(s) found:
foo,tag=100.rds

Wish

Extend the template syntax to specify such fields as well. Maybe, by backslash escaping reserved symbols, e.g.

> dirdf::dirdf_parse("foo,tag=100.rds", template = "name,~tag~=bin\\_size.rds")
  name bin_size rds        pathname
1  foo      100 rds foo,tag=100.rds

or through an unlikely filename symbol such as backtick, e.g.

> dirdf::dirdf_parse("foo,tag=100.rds", template = "name,~tag~=`bin_size`.rds")
  name bin_size rds        pathname
1  foo      100 rds foo,tag=100.rds

BTW, being able to escape as above, we can also do:

> dirdf::dirdf_parse("foo,my_tag=100.rds", template = "name,~my\\_tag~=binsize.rds")
  name binsize rds        pathname
1  foo     100 rds foo,tag=100.rds

to drop the my_tag part of the filename, rather than the tedious:

> dirdf::dirdf_parse("foo,my_tag=100.rds", template = "name,~my~_~tag~=binsize.rds")
  name binsize rds        pathname
1  foo     100 rds foo,tag=100.rds

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