# OpalR: Debugging Table Import Fails

**URL:** <https://datashield.discourse.group/t/opalr-debugging-table-import-fails/737>\
**Category:** Analyst Support\
**Created:** [8 March 2023 15:21 UTC](https://datashield.discourse.group/t/opalr-debugging-table-import-fails/737 "2023-03-08T15:21:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aakkoc](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/aakkoc/32/200_2.png) [@aakkoc](https://datashield.discourse.group/u/aakkoc)\
**Post date:** [8 March 2023 15:21 UTC](https://datashield.discourse.group/t/opalr-debugging-table-import-fails/737/1 "2023-03-08T15:21:51Z")

</div>

We are having some trouble with [`opal.table_import`](https://www.obiba.org/opalr/reference/opal.table_import.html) from [opalr](https://www.obiba.org/opalr/index.html).

```R
> opal.table_import(o,
                   paste0("/projects/Test_Project/",fileSavePath),
                   project='Test_Project',
                   table="tab"
                   )

```

**Error: Import of “/projects/Test\_Project/'temp-data-csv.rds” ended with status: FAILED.**

```R
> opal.tasks(o)

```

| | id | type | user | project | startDate | endDate | status |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | 1 | import | administrator | Test\_Project | 2023-03-08T14:55:27.242Z | 2023-03-08T14:55:28.409Z | FAILED |

You may assume that:

- The file passed for import is a Tibble stored as an RDS.
- The tibble in question is a table with N rows and 4 columns, with sparse `NA` values.
- The project `Test_Project` already exists.
- The table `tab` does not already exist.

Any idea what may have gone wrong, or how to fix it?

Reprex:

```R
#Load Packages:
library(DSI)
library(DSOpal)
library(dsBaseClient)
library(readr)
library(opalr)

library(sys) #Env Vars
library(dotenv) #Env Vars

DEFAULT_CONNECTION_SERVER <- Sys.getenv('DEFAULT_CONNECTION_SERVER')
DEFAULT_CONNECTION_URL <- Sys.getenv('DEFAULT_CONNECTION_URL')
DEFAULT_CONNECTION_USER <- Sys.getenv('DEFAULT_CONNECTION_USER')
DEFAULT_CONNECTION_PASSWORD <- Sys.getenv('DEFAULT_CONNECTION_PASSWORD')

# Read .csv
data <- read_delim(paste0('../../studyfolder/study0/registry','.csv'), delim=';')
# Convert .csv to .Rds
fileSavePath <- paste0('temp-data-csv','.rds')
saveRDS(data, file = fileSavePath)

# Login to opal
o <- opal.login(DEFAULT_CONNECTION_USER, DEFAULT_CONNECTION_PASSWORD, url = DEFAULT_CONNECTION_URL)

# Create project
if (!opal.project_exists(o, "Test_Project"))
  opal.project_create(o, "Test_Project", database = "mysqldb")

#Get Project Info
opal.project(o, "Test_Project")

#Upload new csv
opal.file_upload(o, fileSavePath, '/projects/Test_Project', all.files = TRUE)

#Table Update
opal.table_import(o, paste0("/projects/Test_Project/",fileSavePath), project='Test_Project',
                   table="tab"
                   )

```

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/yannick/32/19_2.png) [@yannick](https://datashield.discourse.group/u/yannick)\
**Post date:** [8 March 2023 15:41 UTC](https://datashield.discourse.group/t/opalr-debugging-table-import-fails/737/2 "2023-03-08T15:41:54Z")

</div>

Hi,

Use [opal.table\_save()](https://www.obiba.org/opalr/reference/opal.table_save.html) instead, it does all the dirty work for you.

Yannick

---

<div class="post-metadata">

**Author:** ![aakkoc](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/aakkoc/32/200_2.png) [@aakkoc](https://datashield.discourse.group/u/aakkoc)\
**Post date:** [9 March 2023 13:15 UTC](https://datashield.discourse.group/t/opalr-debugging-table-import-fails/737/3 "2023-03-09T13:15:55Z")

</div>

Thanks, it worked like a charm!

Can I ask if [`opal.table_import`](https://www.obiba.org/opalr/reference/opal.table_import.html) has been deprecated or something? I just want to know if I did anything wrong. 🙂

---

<div class="post-metadata">

**Author:** ![yannick](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/yannick/32/19_2.png) [@yannick](https://datashield.discourse.group/u/yannick)\
**Post date:** [9 March 2023 14:21 UTC](https://datashield.discourse.group/t/opalr-debugging-table-import-fails/737/4 "2023-03-09T14:21:29Z")

</div>

The opal.table\_import function is not deprecated as it is used by opal.table\_save 🙂

You can check [the source code](https://github.com/obiba/opalr/blob/master/R/opal.table.R#L327-L415) if you wish.

Regards  
Yannick
