opus-data/OpusData.R

34 lines
911 B
R

#!/usr/bin/env Rscript
# Attach packages to workspace, execute with every new session
source("ReadOpus.R")
# Determine file path
#path <- commandArgs(trailingOnly = TRUE)[1]
#file_name <- commandArgs(trailingOnly = TRUE)[2]
#file_path <- paste0(path, file_name)
file_path <- commandArgs(trailingOnly = TRUE)[1]
print(file_path)
# Convert opus binary file into dataframe
data <- read_opus_univ(file_path, 5)
# Replace last "." with "_", add ".DPT"
#file_name <- paste0(sub(".([^.]*)$", "_\\1", file_name), ".DPT")
# 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('python3 transferData.py', target_path))
#py_run_file("transfer.py",local=FALSE, convert=FALSE)