Function to update the path of the raw data file in a workspace. This function works with .csv, .xls and .xlsx format.

update_path(ws_xml_path, raw_data_path, pos_sap, pos_sa_item, verbose = TRUE)

Arguments

ws_xml_path

the path to the xml file of the workspace

raw_data_path

the new path to the raw data

pos_sap

the index of the SA-Processing containing the series (Optional)

pos_sa_item

the index of the SA-Item containing the series (Optional)

verbose

A boolean to print indications on the processing status (optional and TRUE by default)

Value

the workspace ws_to augmented with series present in ws_from and not already in ws_to

Details

The argument pos_sap and pos_sa_item are optional. If pos_sa_item is not supplied, all SA-Item will be updated. If pos_sap is not supplied, all SA-Processing will be updated.

If pos_sa_item is supplied, pos_sap must be specified.

It's also important that the new data file has the same structure as the previous file : - same column names - same column position - same extension and format (.csv, .xls or .xlsx)

Examples


library("RJDemetra")
new_dir <- tempdir()
ws_template_path <- file.path(system.file("extdata", package = "rjdworkspace"),
                         "WS")

# Moving the WS in a temporary environment
copy_ws(
    ws_name = "ws_example_path",
    from = ws_template_path,
    to = new_dir
)
#>  Successful copy!

# Moving the raw data in a temporary environment
data_path <- file.path(system.file("extdata", package = "rjdworkspace"),
                       "data_file.csv")
file.copy(
    from = data_path,
    to = new_dir
)
#> [1] TRUE

path_ws <- file.path(new_dir, "ws_example_path.xml")
new_raw_data_path <- file.path(new_dir, "data_file.csv")

update_path(
    ws_xml_path = path_ws,
    raw_data_path = new_raw_data_path,
    pos_sap = 1L,
    pos_sa_item = 1L:2L
)
#> xmlns: URI ec/tss.core is not absolute
#> xmlns: URI ec/tss.core is not absolute
#> Done!
update_path(
    ws_xml_path = path_ws,
    raw_data_path = new_raw_data_path,
    pos_sap = 1L
)
#> xmlns: URI ec/tss.core is not absolute
#> xmlns: URI ec/tss.core is not absolute
#> xmlns: URI ec/tss.core is not absolute
#> Done!
update_path(
    ws_xml_path = path_ws,
    raw_data_path = new_raw_data_path
)
#> xmlns: URI ec/tss.core is not absolute
#> xmlns: URI ec/tss.core is not absolute
#> xmlns: URI ec/tss.core is not absolute
#> Done!