35 lines
932 B
R
35 lines
932 B
R
#!/usr/bin/env Rscript
|
|
|
|
# Attach packages to workspace, execute with every new session
|
|
library("filesstrings")
|
|
source("ReadOpus.R")
|
|
|
|
# Determine file path
|
|
path <- commandArgs(trailingOnly = TRUE)[1]
|
|
file_name <- commandArgs(trailingOnly = TRUE)[2]
|
|
file_path <- paste0(path, file_name)
|
|
|
|
# Convert opus binary file into dataframe
|
|
data <- read_opus_univ(file_path, 5)
|
|
|
|
# Move the file to OPUS_old where it will remain temporarily in case of an error
|
|
file.move(file_path, "OPUS_old/", overwrite = TRUE)
|
|
|
|
# Replace last "." with "_", add ".DPT"
|
|
file_name <- paste0(sub(".([^.]*)$", "_\\1", file_name), ".DPT")
|
|
|
|
# Determine target, where the result should appear
|
|
target_path <- paste0(path, "../DPT/", file_name)
|
|
|
|
# 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', file_name))
|
|
|
|
|
|
|