I trying to download as csv from grav site using data-manager , But getting error - grav

I trying to download as csv , But getting error

It's not a core library issue. An unnecessary forward slash is causing this.
Temporary solution -
Open user/plugins/data-manager/data-manager.php
Goto line 251 and remove '/' added. The entire path along with the filename is already created on the 249
3. The second parameter is also completely unnecessary. You can just make it
$csv_file = File::instance($tmp);

Related

Reading Excel: evaluation error with zip file cannot be opened [duplicate]

I am using R with readxl package. I try to import an Excel file with the following command:
library(readxl)
city_codes <- read_excel("./data/file.xlsx", sheet = "city_codes")
It says it is a zip file and cannot be opened:
Error in sheets_fun(path) :
Evaluation error: zip file './data/file.xlsx' cannot be opened.
Any ideas?
I had this error, but for me, it was just that I had the sheet open in Excel while trying to read it into R. I guess the package wrongly perceives it as a zip file when it's trying to read it while Excel has partial ownership of it (and this blocks the read).
The error message is readxl's funny way of saying "file not found". That exact line of code gives me the exact same error, and the file doesn't even exist for me.
Note: I'm on version 1.0.0 of readxl
For me the "Evaluation error: zip file" error message also appeared when the excel spreadsheet was still opened in MSExcel.
You can specify a path to a file, only if it is nested on the working directory.
For example: If your working directory is MyWD and there is a folder in it, named MyData and another folder within MyData named MyNestedData, and finally myExcelFile.xlsx
read_excel("MyData/MyNestedData/myExcelFile.xlsx",sheet = "Sheet2") #will work
read_excel("MyWD/MyData/MyNestedData/myExcelFile.xlsx",sheet = "Sheet2") #will not work
If your excel worksheet is password protected, read_excel won't be able to access it and will give you this error.
If it needs protection, I would suggest p/w protecting the folder it's in, and then unprotecting the worksheet.
You may also get this error if you are using the wrong read function.
For example, read_xlsx("file.xls" ...) will throw the error.
This can happen if you forget to do the following before you use the read_excel function
setwd("C:\\map\\map_in_map\\map_in_map_in_map_where_the_file_is")
Try to change file restrictions if you are working on company's computer. This worked for me to solve this issue.
You may try to specify the full path instead of ./path/to/file
Try to make a new file. click "save as" and make a new name. Run again your code. it worked well to me :)
Although the solution was already given, but for the sake of documentation I will leave my situation here:
I ran into the same problem and couldn't figure out why. It seems that my excel file had closed with an error or something similar. I had to open the excel file, and save it again. When I ran R, everything worked smoothly.
The issue was that there was hidden files inside my working directory. I copied them to outside and exclude all directories. Now it works when I run the code.
In my case the xlsx was created using Excel 2007, which caused this issue. Xlsx files from newer Excel versions work.
In my case the file was not visible in the directory although I had deleted it. I had to search for the file using a software called "Everyting" and I deleted it. After that it worked.
For me, I was downloading a file from Google Drive into a tempfile with extension .xlsx... Realised the file in Google Drive was .xls so I changed it to that and it worked. Kinda rare situation though.
I got the same error message.
In my case the line that worked properly specified the sheet by a string (copied from excel). Suddenly, it did not work anymore (with the mentioned error message). I tried several things explained here. Ended up specifying the sheet by its number in the excel file - worked!
read_xlsx("table.xlsx", sheet="name_of_sheet") # suddently corrupt
read_xlsx("table.xlsx", sheet=4) # works
Why? No update of the package or something. I dislike to have to use a less specific line.
UPDATE: Restarting the R session made the initial line work again (although, I HAD checked the wd before...)

OfficeR error: "Docx is already edited", but file doesn't even exist yet. What could be going on?

I have a problem that would be difficult to replicate, thats why i just want ideas of what could be behind this error. When i create a docx an want to save it in the NAS in my office, i would get this error (where doc2 is the docx and Direc4 is my direction):
Error in print.rdocx(doc2, target = Direc4) :
H:\DpProMon\DPM\Programa Monetario Diario\2021\Actas\23 Ago Informe
comité monetario y cambiario.docx is already edited. You must close
the document in order to be able to write the file.
Nevertheless, the File dont exist yet. what could be going on?
Sometimes when im triying to save an actual Word using office, i could get an error that someone else is editing the file (while thats not actually true), and that error would dissapear after a couple seconds. But in R this error doesnt stops. Some help?
In my case I couldn't find the temp file. I deleted cache, temp files from word and local, hidden files in my folder..etc. Could be because in my case I'm using GitHub desktop and also Dropbox so maybe that adds more temp files. The only solution was to change the name of the printed file each time you want to save it. Silly but works.

Reading Excel: evaluation error with zip file '..file.xlsx' cannot be opened

I am using R with readxl package. I try to import an Excel file with the following command:
library(readxl)
city_codes <- read_excel("./data/file.xlsx", sheet = "city_codes")
It says it is a zip file and cannot be opened:
Error in sheets_fun(path) :
Evaluation error: zip file './data/file.xlsx' cannot be opened.
Any ideas?
I had this error, but for me, it was just that I had the sheet open in Excel while trying to read it into R. I guess the package wrongly perceives it as a zip file when it's trying to read it while Excel has partial ownership of it (and this blocks the read).
The error message is readxl's funny way of saying "file not found". That exact line of code gives me the exact same error, and the file doesn't even exist for me.
Note: I'm on version 1.0.0 of readxl
For me the "Evaluation error: zip file" error message also appeared when the excel spreadsheet was still opened in MSExcel.
You can specify a path to a file, only if it is nested on the working directory.
For example: If your working directory is MyWD and there is a folder in it, named MyData and another folder within MyData named MyNestedData, and finally myExcelFile.xlsx
read_excel("MyData/MyNestedData/myExcelFile.xlsx",sheet = "Sheet2") #will work
read_excel("MyWD/MyData/MyNestedData/myExcelFile.xlsx",sheet = "Sheet2") #will not work
If your excel worksheet is password protected, read_excel won't be able to access it and will give you this error.
If it needs protection, I would suggest p/w protecting the folder it's in, and then unprotecting the worksheet.
You may also get this error if you are using the wrong read function.
For example, read_xlsx("file.xls" ...) will throw the error.
This can happen if you forget to do the following before you use the read_excel function
setwd("C:\\map\\map_in_map\\map_in_map_in_map_where_the_file_is")
Try to change file restrictions if you are working on company's computer. This worked for me to solve this issue.
You may try to specify the full path instead of ./path/to/file
Try to make a new file. click "save as" and make a new name. Run again your code. it worked well to me :)
Although the solution was already given, but for the sake of documentation I will leave my situation here:
I ran into the same problem and couldn't figure out why. It seems that my excel file had closed with an error or something similar. I had to open the excel file, and save it again. When I ran R, everything worked smoothly.
The issue was that there was hidden files inside my working directory. I copied them to outside and exclude all directories. Now it works when I run the code.
In my case the xlsx was created using Excel 2007, which caused this issue. Xlsx files from newer Excel versions work.
In my case the file was not visible in the directory although I had deleted it. I had to search for the file using a software called "Everyting" and I deleted it. After that it worked.
For me, I was downloading a file from Google Drive into a tempfile with extension .xlsx... Realised the file in Google Drive was .xls so I changed it to that and it worked. Kinda rare situation though.
I got the same error message.
In my case the line that worked properly specified the sheet by a string (copied from excel). Suddenly, it did not work anymore (with the mentioned error message). I tried several things explained here. Ended up specifying the sheet by its number in the excel file - worked!
read_xlsx("table.xlsx", sheet="name_of_sheet") # suddently corrupt
read_xlsx("table.xlsx", sheet=4) # works
Why? No update of the package or something. I dislike to have to use a less specific line.
UPDATE: Restarting the R session made the initial line work again (although, I HAD checked the wd before...)

r function unzip error 1 in extracting from zip file

Environment:
Windows 7 OS
RStudio Version 0.99.491
I have been programming in R for about 4 months via the Coursera Data Science curriculum, but I have NEVER been successful in using the unzip function.
I've looked at the forums for hours for potential solutions, syntax problems, undefined arguments, etc., but to no avail. I eventually unzip the contents manually and proceed with the assignment, but I am tired of not knowing why it is not working.
Here are a few examples of the error:
fileName <- "StormData.zip"
unzip(fileName, exdir = mainDir,subDir)
Warning message: In unzip(fileName, exdir = mainDir, subDir) : error
1 in extracting from zip file
unzip(fileName)
Warning message: In unzip(fileName) : error 1 in extracting from zip
file
unzip(fileName, "stormdata.csv")
Warning message: In unzip(fileName, "stormdata.csv") : error 1 in
extracting from zip file
unzip(fileName, "stormdata.csv", list = TRUE)
Error in unzip(fileName, "stormdata.csv", list = TRUE) : zip file
'StormData.zip' cannot be opened
Any suggestions would be greatly appreciated.
I was getting the same error.
I changed the path --
from :
uzp <- "C:\\Users\\Sharvari\\Downloads\\rprog%2Fdata%2Fspecdata"
to
uzp <- "C:\\Users\\Sharvari\\Downloads\\rprog%2Fdata%2Fspecdata.zip"
and it works fine!
setwd("C:\\Users\\Sharvari\\Downloads")
uzp <- "C:\\Users\\Sharvari\\Downloads\\rprog%2Fdata%2Fspecdata.zip"
unzip(uzp, exdir = "C:\\Users\\Sharvari\\Desktop\\specdata")
I too was getting that error 1 message when trying to unzipping a zip file. Glitch in my case was the conflict between working directory and zip file path.
My case was:
My working directory was like "C:/Users/SCOTT/Desktop/Training"
While my zip file was located in "C:/Users/SCOTT/Desktop/Training/house_consumption_data"
When I was trying to execute this:
unzip("house_data.zip")
Possibly your file is in a different folder.
I have had the same problem trying to download and unzip the same file, for the same course. And I have had problems with unzip in the past and was determined to solve it this time too.
Eventually the extension of the file turned out to be csv.bz2. And than this Extract bz2 file in R post solved my problem.
After downloading the file I was able to read it directly with
stormdata <- read.csv("stormdata.zip")
without using unzip.
This error seems to appear whenever openXLS is unable to open the specified file.
It could be a wrong name, wrong directory or the file might be encrypted or password protected
change your zip file format this error will appear while the zip format problems occur, look at your zip file it should be "rar" change it to "zip". the function works only for "zip" format files.
I faced the same issue. Make sure that, you specify the correct name of the file(get it from the properties of .zip file) in the following code.
file = read.table(unzip("file_name.csv.zip"), sep = ",", header = TRUE)
In my case, Was just mentioning file_name.zip and R was throwing the error.
Also, there are two functions for unzipping files in R
1) unz - to extract single element from zip file/s
2) unzip - to extract all the present elements from the .zip file
I usually prefer unzip.
If you will use unz in the above code, R will throw error again.
I encountered the same error using install_course_zip' with a zip file. I followed all the instructions for the command faithfully but kept getting errors relating to the 'exdir'. I moved the zip file to various directories without success.
I finally used getwd() to get the working directory and then placed the zip file in that directory. I then was able to use the zip file name without having to use any folder structure and this worked. I still have no idea why R would not accept a different directory.
I had list of files to be unzipped and processed; I was facing same error
"error 1 in extracting from zip file"
used full directory and set working directory code worked
files <- list.files(path="C:\\Users\\Tejas naik\\Documents\\land", pattern=".zip$")
out_dir<- "C:\\Users\\Tejas naik\\Documents\\input"
setwd("C:\\Users\\Tejas naik\\Documents\\land")
for (i in files) {
#nzip(paste(out_dir,i), exdir=out_dir)
unzip(i,exdir=out_dir)
}
This error was happening bit differently in my case . As there was no zip file ,the issue was file was open in excel so this error was poping up .
It's crucial to give the full name (including the path) of the zip-file to the unzip function.
So instead of file.zip, it should be C:\user\name\file.zip.
In case you're using the list.files function, one should set the full.names option to TRUE.
For me the error is fixed after I add \ backslash character to the filepath.
Example:
from
unzip("abc\aaa.zip")
to
unzip("abc\\aaa.zip")

How to figure out number of files in specific folder on server?

I have been trying to find a way to get the count of how many files are in a folder called "images", which is in a folder I am already in.
This is the code I have been trying but I have been getting an error message:
Code:
count = System.IO.Directory.GetFiles(System.Web.HttpContext.Current.Server.MapPath("/images"),
"(asterisk symbol).(asterisk symbol)").Count()
The error message says it can't find the path.
When debugging a problem, break the line of code in to smaller pieces to make it earier to see. I would first print out the value of System.Web.HttpContext.Current.Server.MapPath("/images"). Then see if that's a real folder. .

Resources