2021-01-14 14:49:30 +01:00
|
|
|
#!/usr/bin/env Rscript
|
2021-01-19 11:09:12 +01:00
|
|
|
|
2021-02-19 09:21:25 +01:00
|
|
|
# Attach packages to workspace, execute with every new session
|
2021-01-27 15:49:11 +01:00
|
|
|
source("ReadOpus.R")
|
2021-01-19 11:09:12 +01:00
|
|
|
|
2021-01-19 14:26:16 +01:00
|
|
|
# Determine file path
|
2021-03-05 14:26:13 +01:00
|
|
|
#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)
|
2021-01-14 14:49:30 +01:00
|
|
|
|
2021-01-27 15:49:11 +01:00
|
|
|
# Convert opus binary file into dataframe
|
2021-02-08 18:21:39 +01:00
|
|
|
data <- read_opus_univ(file_path, 5)
|
2021-01-14 14:49:30 +01:00
|
|
|
|
2021-02-19 09:21:25 +01:00
|
|
|
# Replace last "." with "_", add ".DPT"
|
2021-03-05 14:26:13 +01:00
|
|
|
#file_name <- paste0(sub(".([^.]*)$", "_\\1", file_name), ".DPT")
|
2021-01-15 15:39:19 +01:00
|
|
|
|
2021-02-19 09:21:25 +01:00
|
|
|
# Determine target, where the result should appear
|
2021-03-05 14:26:13 +01:00
|
|
|
target_path <- paste0("/tmp/", sub('.*\\/', "", file_path))
|
2021-01-19 11:09:12 +01:00
|
|
|
|
2021-02-19 09:21:25 +01:00
|
|
|
# Create file
|
|
|
|
file.create(target_path)
|
2021-01-15 15:39:19 +01:00
|
|
|
|
2021-02-19 09:21:25 +01:00
|
|
|
# Fill file with dataframe
|
|
|
|
write.table(data, target_path, row.names = FALSE, col.names = FALSE, sep = ",")
|
2021-01-15 15:39:19 +01:00
|
|
|
|
2021-02-19 09:21:25 +01:00
|
|
|
# Call python script
|
2021-03-05 14:26:13 +01:00
|
|
|
system(paste('python3 transferData.py', target_path))
|
|
|
|
#py_run_file("transfer.py",local=FALSE, convert=FALSE)
|
2021-01-19 14:26:16 +01:00
|
|
|
|
|
|
|
|