5.2.2: How to Incorporate Data Files in Your Code Blocks- For Julia
- Page ID
There are a number of ways data files and can be incorporated into code blocks. However, ensure that you have already followed the steps in the introduction to the CKEditor Binder Plugin Tutorial here.
Method 1: Using Julia Packages
Simply replace the URL of your data file in the below example code block to load your data in.
import Pkg; Pkg.add("HTTP") import Pkg; Pkg.add("DelimitedFiles") using HTTP using DelimitedFiles data = HTTP.get("https://chem.libretexts.org/@api/deki/files/265970/auto-mpg.data") myCSV = readdlm(data.body)
Method 2: Using wget or other shell commands
The second method that can be used to get a data file in your code block is with wget.. Note that the command is contained in backticks, not normal single quotes. Shell commands will not work with normal single quotes. Follow the example below and replace the example URL with the one attained in the previous step. Once the file is loaded, read and utilize it just as you would on your local computer.
Note: using the run command allows the user to run any shell command in Julia