How to Import and Use CSV file into Julia (Windows)

1021
Import and Use CSV file into Julia
Import and Use CSV file into Julia

In this short tutorial, we will learn how to import and use the CSV file into Julia on windows 10.

The first thing all you need to do is install Julia language and Jupyter notebook.

Once you complete the installation, then connect Julia to Jupyter notebook. So that Jupyter knows about Julia and you can run code on the notebook.

Now, we will show you how to import and use CSV file into Julia using the following platforms:

1. Julia Command Prompt

2. Jupyter Notebook

Method #1: Using Julia Command Prompt

Here, we will import CSV file using the Julia command prompt.

Follow the steps to import and use CSV file on your local machine.

Step #1: Open Command Prompt and Add Package

Open the Julia command prompt and install CSV package. In order to add CSV package, type the following commands at Julia command prompt then press Enter.

Intedrating CSV package into Julia
CSV Package Installation

You use Pkg for adding any packages. Since Pkg itself is a package so you have to import it through the using command.

This will download and install the CSV package along with its stuff.

Once you add the CSV package, you are now ready to import the dataset for wrangling, manipulation, and visualization.

Step #2: CSV Dataset Collection

In this tutorial, we will be using the iris flower dataset. Here, we downloaded and store the dataset on the desktop.

Below is an excerpt of iris dataset.

Iris dataset after importing and use in Julia on windows
Excerpt of Iris Dataset

Step #3: Import and Use the Dataset using CSV

Now, you type the following command along with its path name of your file.

It is worth mentioning that you use a double backslash within the path name instead of a single slash.

You should see a screenshot like this after reading the dataset.

Displaying iris dataset in Julia
Displaying Iris Dataset

Method #2: Using Jupyter Notebook IDE

Step #1: Open Jupyter Notebook and Add Package

First you launch the Jupyter notebook through the Anaconda navigator. After opening the notebook, you need to add CSV package.

Once you have installed the package then follow the below steps.

Step #2: Import and Use CSV file

In order to import the CSV dataset, we will use the commands in a notebook and then run the code.

After running, you will get the following output.

Import and use iris csv dataset in julia
Importing Iris Flower Data

Just keep in mind that you store the dataset and CSV package in the same folder to avoid the error.

No need to mention the path name in the source code as you can upload files directly in the working directory.

Hopefully this post was useful to you. Now, you can import and use CSV file into Julia on windows operating system.

LEAVE A REPLY

Please enter your comment!
Please enter your name here