opus-data/OpusData.R
2021-03-11 16:45:24 +00:00

29 lines
675 B
R

#!/usr/bin/env Rscript
# Attach packages to workspace, execute with every new session
source("ReadOpus.R")
# Determine file path
file_path <- commandArgs(trailingOnly = TRUE)[1]
# Convert opus binary file into dataframe
tryCatch(data <- read_opus_univ(file_path, 5), error=function(e){
print("Failed converting OPUS file")
exit()
}
)
# Determine target, where the result should appear
target_path <- paste0("/tmp/", sub('.*\\/', "", file_path))
# Create file
file.create(target_path)
# Fill file with dataframe
write.table(data, target_path, row.names = FALSE, col.names = FALSE, sep = ",")
# Call python script
system(paste('./transfer-data.sh', target_path))