简体   繁体   中英

pdf files created in R databricks using pdf() function are not getting created in Azure Blob storage

I tried both the codes, but pdf file is not getting created in Azure Blob storage and R is not throwing any error also. I have mounted blob in dbfs and using it. Delta, csv, text files are getting created and stored without any issue using the same mount path.

code -1

df = data.frame(matrix(rnorm(400), nrow=100))
dfplot = ggplot(df, aes(x=X1,X2))+geom_point()
pdf('/dbfs/mnt/blobstorage/test.pdf')
print(dfplot)
dev.off()

code-2

install.packages('quantmod')
library(quantmod)

gs <-function(f) {
    csv <- read.csv(text="s,n\nF,Ford\nV,Visa", header=TRUE, stringsAsFactors=FALSE)
    symVec <- getSymbols(as.vector(csv$s))
    infoVec <- mapply(paste, csv$s, csv$n, sep=": ") # eg. "F: Ford"
    pdf("/dbfs/mnt/blobstorage/test.pdf")
    par(mfrow=c(5,7))
    print(mapply (chart_Series, mget(symVec), name=infoVec))
    dev.off()
}

main <- function() {
    # get symbols, create pdf
    gs(f)
}

if(!interactive()) {
    main()
}

I have been able to do it with the following work around: 1) Write the pdf file to a temporary directory 2) copy the file to the DBFS dir.

dir_Temp <- tempdir()
print(dir_Temp)

setwd(dir_Temp)
X1 <- rnorm(100)
X2 <- rnorm(100)
pdf('test3.pdf')
plot(X1, X2)
dev.off()

file.copy(from = paste0(dir_Temp, "/", "test3.pdf"), 
          to = "/dbfs/FileStore/test_Databricks/test3.pdf")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM