How to load file in SageMath 7.1 - sage

I am new to Sage & I wish to load a .sage file from a Sage Notebook worksheet.
I am on OSX 10.9.5.
If I evaluate
load (example.sage)
I get
IOError: did not find file 'example.sage' to load or attach
The example file is on my Desktop.
Do I need to explicitly state the full file path?
If so how?
Thx.

There are two ways to load that file located on your desktop.
One way is using ~ to denote your home directory:
load('~/Desktop/example.sage')
The other one is to use the full path:
load('/Users/username/Desktop/example.sage')
(replacing username by your actual username).

Related

loading downloaded data to Rstudio

mission on online course:
Download this RData file to your working directory. Then load the data into R with the following command:
load("skew.RData")
so I have downloaded it to my computer but where is my working directory? or how do I load the downloaded file to Rstudio
You can see your working directory by executing getwd().
In order to load the data you need to change it to the folder path where the data is stored.
setwd("C:/your/path")
load("skew.RData")
You can set you working directory in RStudio on the right side manually and then save the files there and open them like :
load("skew.RData")
If your file is saved somewhere else, you should define the path to it:
load("path/to/your/file/skew.RData")

Unable to load data file in Julia

There is a CSV file called orders_data stored in my system, but when I try to load this file in Julia using readdlm command in Jupyter Notebook(running in my browser), it says "NO SUCH FILE DIRECTORY FOUND"
I'm not sure why does this happen? is there a specific location where the files need to be stored to be accessed using Julia command? is it that I need to install some packages first to load the file using browser version of jupyter?
//Error information
SystemError: opening file orders_data.csv: No such file or directory
Your working directory is set to your current location when you start a Julia session. You can see what it is by calling the pwd() function. You can change it by calling the cd() function. Unless you specify otherwise, or provide a more complete pathname, Julia looks for files in your current working directory (although it's different for modules).

pyspark: how to show current directory?

Hi I'm using pyspark interactively. I think I'm failing loading a LOCAL file correctly.
how do I check current directory, so that I can go to browser to take a look at that actual file?
Or is the default directory where pyspark is? Thanks
You can't load local file unless you have same file in all workers under same path. For example if you want to read data.csv file in spark, copy this file to all workers under same path(say /tmp/data.csv). Now you can use sc.textFile("file:///tmp/data.csv") to create RDD.
Current working directory is the folder from where you have started pyspark. You can start pyspark using ipython and run pwd command to check working directory.
[Set PYSPARK_DRIVER_PYTHON=/path/to/ipython in spark-env.sh to use ipython]
import os
cwd = os.getcwd()
print(cwd)

system command to open a file in r

need help to open a file in system directory like pdf file in
path ="c:\\abc\\xyz.pdf" with system default pdf viewer
Or to open image in folder using system default photo viewer
already try system('"E:\\pdf_ka_zakhera\\9780387981406-c1.pdf"') in R
Try this:
shell("E:\\pdf_ka_zakhera\\9780387981406-c1.pdf")
From "shell" help page:
To make use of Windows file associations, use shell.exec

How to permanently set fix my working dir?

Every time I restart R I issue the following command:
setwd("C:/Users/avtarsingh/Downloads")
How do make this my permanent working dir
Create a file called ".Rprofile" and add that command. R will look for this file every time it starts and change to that directory accordingly. More info in the R documentation here
In order to change your working directory permanently, you can find the following file “Rprofile.site” that is located in your installation path “etc” folder and open it in your favorite text editor (i.e., VSCode). Then you can add your permeant working directory to the first line, like the following line of code:
setwd(“C:\your permeant working directory”)
and save it. Next time you open the R-CRAN, your working directory is set to what you have saved.
Any code which you wish to run every R session can be added to Rprofile.site.
On a Windows machine, this file is located for example in C:\Program Files\R\R-3.1.2\etc. On Windows you will need to run your favourite text editor as an administrator to make changes to this file, since it is in Program Files.
This is also a good place to set your local CRAN repository, etc.

Resources