i was trying to import csv file to postres using this command.
copy zip_codes from '/path/to/csv/ZIP_CODES.csv' DELIMITERS ',' CSV;
but i m getting an error "/path/to/csv/ZIP_CODES.csv:Permission Denied".
i came across with a solution of using \copy instead of copy but its not working probably because it dosent work in windows
How to change the permission of the file.
I m working on windows7.
The \COPY command should work in Windows. Try adding the drive letter (like "C:") to the front of the path. Also remove "DELIMITERS ','" as that's redundant since you're using CSV format.
It would also help if you added the error message from the \COPY command.
Related
I'm trying to make the my code portable to Windows and realized that even though I use file.path to create paths still the readRDS function won't work, for example:
file.exists('C:/temp/HarvardX-Skillability/data/rds/Users.rds')
> TRUE
readRDS('C:/temp/HarvardX-Skillability/data/rds/Users.rds')
> Error in readRDS("C:/temp/HarvardX-Skillability/data/rds/Users.rds") :
error reading from connection
I also tried:
file.exists('data/rds/Users.rds')
> TRUE
readRDS('data/rds/Users.rds')
> Error in readRDS("data/rds/Users.rds") : error reading from connection
Why is that? and how can I fix it? In Ubuntu 18.04 works perfectly ...
The problem seems to be with downloading/cloning the files from GitHub. After running git clone on your repository, when I open my local copy of Tags.rds in a text editor I see this:
version https://git-lfs.github.com/spec/v1
oid sha256:b4a2cb3775126a3895e9533ef9ef4ad786b2021cfd1660b07028fbef85b025bb
size 641098
(this is the entire contents of the file). Furthermore, running file Tags.rds (in a Terminal on MacOS) reports Tags.rds: ASCII text. (All of the .rds files are like this.)
The GitHub web interface confirms that your files are OK on the repo:
This question looks related. After installing Git LFS and running git lfs pull, I get the full file downloaded (and readRDS() seems to work fine).
The culprit to the OP was something really unexpected, I also didn't provide the information for it because I couldn't suspect this was the issue.
The problem was those files were being downloaded automatically using download.file(url, filePath, extra="L") and in Windows this is known to cause issues with binary files that are not the expected ones. This is why the rds files were unrecognizable.
I found out while building exception handling recovery code that was looking to download the same files from a Dropbox folder and then came to the same issue, therefore it wasn't because of Git LFS.
The OP solution was to add the argument download.file(..., mode="wb").
See the question R trouble unzipping file under Windows
I tried to run an Rscript file from my ubuntu terminal on the server using the code:
Rscript etl/ConceptTables/loadTables.R mimiciii"
The file is located in stated directory below but I need to run the script from the root directory. However, it is saying this file does not exist but it clearly does. I also tried running this by entering the R environment first but instead, I get:
"Error: Unexpected symbol in "etl/ConceptTables/loadTables.R mimiciii"
I am following instructions from this mimic-omoop ETL on github here: https://github.com/chichukw/mimic-omop/blob/master/README-run-etl.md and I already created the cpg file with my username and database name. Could anyone clarify what I am doing wrong?
Try using the full path of the file. The error you have posted is "Unexpected symbol"
Could be because you have added a double quote at the end of mimiciii. Or is it a mistake while posting the question?
If you are using double quotes for the path, ensure that it is " and not “.
I am trying to use wkhtmltopdf to turn website content into pdf and then read it into my R. So I write in my COMMAND PROMPT line to download as html front page of yahoo finance (just for fun). So i create "TemporaryFolder" on my C and write in cmd:
C:\Program Files\wkhtmltopdf\bin>wkhtmltopdf https://finance.yahoo.com/ "C:/TemporaryFolder/myhtml.pdf"
And it downloads yahoo finance website as pdf. Now I want to do the same thing but using R script. I know there is system function however I have very little experience with it (and with cmd to be honest).
So now i try use this command in my Rstudio so I can later create R script which downloads website as html and converts it to pdf.
URL="https://finance.yahoo.com/"
wkhtmltopdf_dir="C:/Program Files/wkhtmltopdf/bin"
save_as="C:/TemporaryFolder/myhtml.pdf"
x=paste0(wkhtmltopdf_dir,">","wkhtmltopdf"," ",URL," ",'\"',save_as,'\"')
system(x)
I also tried shell(x) but I got "permission denied".
But it does nothing... Could someone elaborate how system works and what should be added here?
BTW: can I harm my computer by using system? For example writing some "bad" command? This question might sound silly, but I am really to new to this.
What you're trying to paste as a command ("C:/Program Files/wkhtmltopdf/bin>wkhtmltopdf https://finance.yahoo.com/ \"C:/TemporaryFolder/myhtml.pdf\"") doesn't quite work. The first part ("C:/Program Files/wkhtmltopdf/bin>) is actually the prompt when you run it in commander. It's not a part of the command, but instead shows in which directory you are running that command.
If you replace wkhtmltopdf with C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe, it should work just fine:
URL="https://finance.yahoo.com/"
wkhtmltopdf_exe="C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe"
save_as="C:/TemporaryFolder/myhtml.pdf"
x=paste0(wkhtmltopdf_exe," ",URL," ",'\"',save_as,'\"')
system(x)
To answer your second question, a call to system() runs the command through CMD. So basically anything you could mess up through CMD.exe, you can mess up through system().
I figured out what was wrong. As i posted in comment, after using shell(x) instead of system(x) it returned 'C:/Program' is not recognized as an internal or external command, operable program or batch file.. So I reinstalled my wkhtmltopdf to folder which name contains no spaces. So wkhtmltopdf_exe is now:
wkhtmltopdf_exe="C:/Programs/wkhtmltopdf/bin/wkhtmltopdf.exe"
Rest of the code is the same. Followup here would be nice, is there any way to workaround spaces in folder names? Or should I always avoid spaces? Putting wkhtmltopdf path into quotation marks didnt help.
Thank for user JAD for fixing my first code
I am using Scinote 5.4.0 with OSX 10.7.4. I am unable to execute script files from the console using the exec("path") command; when I do so, only the first line of the script file is read.
Example:
-->exec("plot1.sce")
-->x=[0:.1:10]'; //(the first line of my code)
If however I "execute with echo" from the editor Scinote, the script will run just fine.
Does anybody know what is going on? (The script files I am trying to run are in my present working directory).
Thanks!
Update: I just installed Scilab on an identical machine and the same thing is happening.
Update: Per Scilab's bugtracker, it appears to be caused by Scinote defaulting to cr eol on a mac. I don't really know what this means or how to fix it, but the adventure continues!
Update: I found the solution!:http://comments.gmane.org/gmane.comp.mathematics.scilab.user/6184
In the preferences, I changed the eol to Unix, and the default file encoding to iso-8859-1. I restarted and exec is now working!
The link is not easy to follow so here's the answer (pasted)
The problem is actually scinote's, not scilab's. I don't have a Lion
machine to check if I'm correct, but it seems scinote's file encoding
is no longer compatible in ML. I discovered that when I opened scinote
generated files with a different text editor (vi) the new lines
weren't encoded right for my machine. The other give-away was that
executing scripts written prior to upgrading worked fine.
Go to preferences and in the scinotes tab, switch default file
encoding to iso-8859-1. I also switched the end-of-line to Unix.
The documentation states that there is a command-line shell for sqlite3:
To start the sqlite3 program, just type "sqlite3" followed by the name the file that holds the SQLite database."
When I try this, in the Windows Command Prompt I get the error message:
'sqlite3' is not recognized as an internal or external command,
operable program or batch file.
Windows explorer reveals several 'Sqlite3" folders in various places:
backends(C:/Python26/Lib/site-packages/django/db)
Lib(C:/Python26)
backends(C:/Django-1.1.1/Django-1.1.1/build/lib/django/db
backends(C:/Django-1.1.1/Django-1.1.1/django/db)
How do I access the shell, can anyone help?
Download sqlite3 binary for windows here. Unzip it and put it somewhere in your path.
That's the error message you get if you try to run any executable that's not in your current directory or in the path.
To correct the problem, find the SQLite executable (SQLITE3.EXE), and run it from the directory in which it resides, or add SQLITE3.EXE to your PATH environment variable.
You have to properly set your PATH environment variable to include one of the locations where sqlite3.exe resides. Usually SQLite seems to set that environment variable upon install but the list of paths where you found it indicates that it just came as a library for various other applications. Therefore it's not too surprising that the path isn't set.
I have sqlite3 on my machine, and as others have mentioned it must be located within a folder specified by your PATH environment variable. Since I use it a lot, I threw it in windows\system32, which is where I place a lot of utilities like pstools.