Skip to content

Feature Request: Add support for semicolon-delimited CSV responses (European locales) #570

Description

@mrkskk

Problem Description

When using REDCapR with European REDCap servers, the API returns CSV data with semicolons (;) as field separators instead of commas (,). This causes REDCapR functions to fail because REDCapR functions use readr::read_csv() which is hardcoded to expect comma separators.

Current Behavior

# This fails with European REDCap servers
redcap_variables(redcap_uri = uri, token = token)
# Error: parsing issues due to semicolon separators

The raw CSV returned from European REDCap servers looks like:

field_name;form_name;section_header;field_type;field_label
record_id;demographics;;text;Study ID
name_first;demographics;;text;First Name

But REDCapR expects:

field_name,form_name,section_header,field_type,field_label
record_id,demographics,,text,Study ID
name_first,demographics,,text,First Name

So of course this leads to parsing errors

Why the existing locale parameter doesn't solve this

REDCapR functions accept a locale parameter, but this does not fix the semicolon issue because:

  1. readr::read_csv() is hardcoded for commas - The locale parameter only affects decimal separators, date formats, and encoding, not the field delimiter
  2. Field delimiter is not part of locale settings - readr::locale() cannot change the fundamental CSV structure that read_csv() expects

Proposed Solution

REDCapR should use rreadr::read_delim() (for a configurable delimiter that would work regardless of locale)

and add a delimiter parameter to REDCapR functions that allows users to specify the CSV delimiter:

# Option 1: Add delimiter parameter
redcap_variables(redcap_uri = uri, token = token, delimiter = ";")

# Option 2: Auto-detect based on locale
redcap_variables(redcap_uri = uri, token = token, locale = readr::locale(encoding = "UTF-8"))

Affected Functions

This issue affects all REDCapR functions that parse CSV responses:

  • redcap_read() and related functions
  • redcap_variables()
  • redcap_instruments()
  • redcap_event_instruments()
  • redcap_event_read()
  • redcap_metadata_read()
  • redcap_project_info_read()

Current Workaround

Currently, users must intercept and override REDCapR functions using assignInNamespace() to replace semicolons with commas before CSV parsing. This requires:

  1. Creating custom wrapper functions for each affected REDCapR function
  2. Using assignInNamespace() to override the original functions
  3. Maintaining custom code that duplicates REDCapR's internal logic
  4. Regex manipulation of raw CSV text before parsing

This workaround is very cumbersome.


Metadata

Metadata

Assignees

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions