Incorrectly formatting of Vine identifiers from Excel sources for eBrida. For example, the identifier
Incorrect Excel format | conversion | Correct eBrida format |
---|---|---|
TO8.33.06.15F |
=> | T08.33-06-15f |
x <- scan(what=character(0))
TO8.33.02.01A
TO8.33.02.01B
TO8.33.02.02A
TO8.33.02.02B
""
formatIDs <- function(x){
## Convert TO\\ds => T0\\ds
x <- gsub("^(T)O(\\d)", "\\10\\2", x)
## -'s and lower case
x <- gsub("(.+?\\.)(.+?)\\.(.+?)\\.(.+)","\\1\\2-\\3-\\L\\4", x, perl=TRUE)
return(x)
}
cat("[ MARC IDs ]\n")
print(x)
cat("[ eBrida conversion ]\n")
print(formatIDs(x))
formatIDs <- function(x) {
## Using strsplit
parts <- strsplit(x, "\\.")
## Convert TO\\ds => T0\\ds
st <- gsub("^(T)O(\\d)", "\\10\\2", parts[[1]])
en <- tolower(parts[[4]])
return(paste0(st, ".", parts[[2]], "-", parts[[3]], "-", en))
}
cat("[ MARC IDs ]\n")
print(x)
cat("[ eBrida conversion ]\n")
sapply(idparts, formatIDs)