Write a Dataframe in csv in Dataiku using R - r

I am trying to write a dataframe into CSV using R in Dataiku Managed Folder.
What I have tried:
(From Documentation - https://doc.dataiku.com/dss/latest/connecting/managed_folders.html#usage-in-r)
data must be a connection providing the data to upload
dkuManagedFolderUploadPath("folder_name", "path_in_folder", data)
It says that Data must be a connection. How can I create a connection?
I tried below method but it is creating a binary file and not csv.
save(df, file="sample.csv")
connection <- file("sample.csv","rb")

Related

Convert raw bytes into a NetCDF object

I am pulling in NetCDF data from a remote server using data <- httr:GET(my_url) in an R session. I can writeBin(content(data, "raw"), "my_file.nc") and then nc_open("my_file.nc") but that is rather cumbersome (I am processing hundreds of NetCDF files).
Is there a way to convert the raw data straight into a ncdf4 object without going through the file system? For instance, would it be possible to pipe the raw data into nc_open()? I looked at the source code and the function prototype expects a named file, so I suppose a named pipe might work but how do I make a named pipe from a raw blob of bytes in R?
Any other suggestions welcome.

How to read a CSV file, perform a few Algorithmic operations in python subprocess using native R and save the result in a CSV file?

-> Created two variables for the path of the source CSV file and a destination file where the resultant CSV needs to be saved.
-> All the algorithmic computations are done in native R. And the resultant is stored in a CSV by using write.csv function within R.
Reading the csv:
input_var <- as.xts(read.csv(glue('controller/temp/folder1/abc.csv'), header=TRUE, row.names="datetime"))
#operations in R
writing to csv:
write.csv(var_output[symbol]["desired_key"], file = glue("{folder}result_file.csv") , row.names = FALSE)
the subprocess doesn't save the csv in the desired folder when run in a Docker Container but the same code runs on local.

How to fetch data in R by executing command in excel?

I have to fetch data from Reuters and they provide an excel plugin for that. The problem is that my excel is crashing if I try to fetch too many variables at the same time. I was wondering whether I can do it from R via some excel connection.
In general I want to give the command to excel (from R), fetch data and get the data back in R for analysis. The process has to be repeated a number of times.
=TR("SCREEN(U(IN(Equity(active,public,primary))/*UNV:Public*/))",A1:K10,"PERIOD:FY2015 NULL:-- curn=USD RH=In CH=Fd",A6)
I get the variable name from (A1:K10) and then the output is stored from cell A6 onwards.
The answer https://stackoverflow.com/a/43222477/1389469 here points to RDCOMClient library but I am not able to run the macro from R as described there.
Another guide here https://cran.r-project.org/web/packages/excel.link/excel.link.pdf talks about how to read/write data from an open excel workbook but doesn't tell how to execute commands in excel from R.

Unable to write data in Macro enabled file in R using openxlsx package

When I trying to write data in a Macro enabled file, that excel files gets crashed. Is there any way in R to write data in Macro enabled data keeping the existing data intact. Below is my code:
wb <-loadWorkbook("C:/Test/Excel.xlsm")
writeData(wb,df,sheet="sheet1",startRow=2)
saveWorkbook(wb,"C:/Test/Excel.xlsm", overwrite = TRUE)

Converting R dataframe to H2O Frame without writing to disk

I know the as.h2o function from h2o library converts an R data.frame to an H2O frame. Two questions:
Does as.h2o() write data to disk during conversion? How long is this data stored?
Are there other options that avoids the temp step of writing to disk?
The exact path of running as.h2o on a data.frame, df :
path <- write.csv(df)
h2o.upload(path)
remove.file(path)
We temporarily write to disk the data.frame and then subsequently upload rather than import the file into H2O and as soon as the file is uploaded we delete the temporary frame. There is no cleaner alternative to not writing to disk.

Resources