Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_nircal() fails when IDs contain special characteres #65

Closed
l-ramirez-lopez opened this issue Feb 16, 2024 · 2 comments
Closed

read_nircal() fails when IDs contain special characteres #65

l-ramirez-lopez opened this issue Feb 16, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@l-ramirez-lopez
Copy link
Owner

The read_nircal() fails if the ID column in the .nitr file contains some special characters e.g. L61225_Aldi Süd_02.11.06_ARPA_0001_0002

@l-ramirez-lopez l-ramirez-lopez added the bug Something isn't working label Feb 16, 2024
@l-ramirez-lopez l-ramirez-lopez self-assigned this Feb 16, 2024
@l-ramirez-lopez
Copy link
Owner Author

l-ramirez-lopez commented Feb 16, 2024

Solution:

in get_nircal_ids() replace:

  ids <- strsplit(ids, "\n", useBytes = TRUE)[[1]]
  # ids <- iconv(ids, to = "UTF-8", sub = NA)
  ids <- enc2utf8(ids)
  ids <- ids[-c(1, length(ids))]
  ids <- substr(x = ids, start = regexpr("/", ids) + 1, stop = 100000)

by

  ids <- enc2utf8(ids)
  ids <- strsplit(ids, "\n", useBytes = TRUE)[[1]]
  # ids <- iconv(ids, to = "UTF-8", sub = NA)
  ids2 <- ids[-c(1, length(ids))]
  ids <- try(substr(x = ids2, start = regexpr("/", ids) + 1, stop = 100000))
  if (inherits(ids, "try-error")) {
    ids <- iconv(ids2, from = "Latin1", to = "UTF-8")
  }

@l-ramirez-lopez
Copy link
Owner Author

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant