Deliver geospatial models direct to decision makers with SyncroSim › Forums › SyncroSim – General Questions and Answers › Working with SyncroSim folders using the rsyncrosim package › Reply To: Working with SyncroSim folders using the rsyncrosim package
Unfortunately, the rsyncrosim and pysyncrosim packages do not have built-in folder functions yet. However, being able to create, modify, and access folders in SyncroSim using rsyncrosim and pysyncrosim will become available in an upcoming release. In the meantime, you can use the SyncroSim console commands from R to retrieve a dataframe of existing folder IDs and other folder data.
Here is a function that uses the SyncroSim console commands to retrieve folder data that you can implement in your script. Note that you will need rsyncrosim loaded to use this function.
library(rsyncrosim)
retrieveFolderData <- function(libpath){
args <- list(list = NULL, folders = NULL, lib = libpath, csv=NULL)
tt <- command(args)
con <- textConnection(tt)
out <- read.csv(con)
return(out)
}
retrieveFolderData("path/to/my/library.ssim")
Similarly, in python you can add this function to your script to retrieve folder data. Note that you will need to import the pysyncrosim and io python packages to use this function.
import pysyncrosim as ps
import io
def retrieve_folder_data(libpath):
my_session = ps.Session()
args = ["--list", "--folders", "--lib=%s" % libpath]
tt = my_session._Session__call_console(args, decode=True, csv=True)
out = pd.read_csv(io.StringIO(tt))
return out
retrieve_folder_data("path/to/my/library.ssim")
- This reply was modified 1 year, 6 months ago by katie-birchard. Reason: Added python example