codingPerson
codingPerson

Reputation: 109

How to load a data set into Jupyter Notebook

When loading a dataset into Jupyter, I know it requires lines of code to load it in:

from tensorflow.contrib.learn.python.learn.datasets   import base

 # Data files
IRIS_TRAINING = "iris_training.csv"
IRIS_TEST = "iris_test.csv"

# Load datasets.
training_set =  base.load_csv_with_header(filename=IRIS_TRAINING,
                                         features_dtype=np.float32,
                                         target_dtype=np.int)
test_set = base.load_csv_with_header(filename=IRIS_TEST,
                                    features_dtype=np.float32,
                                    target_dtype=np.int)

So why is ther error NotFoundError: iris_training.csv still thrown? I feel as though there is more to loading data sets on to jupyter, and would be grateful on any help on this topic

I'm following a course through AI adventures, and dont know how to add in the .csv file; the video mentions nothing about how to add it on.

Here is the link: https://www.youtube.com/watch?v=G7oolm0jU8I&list=PLIivdWyY5sqJxnwJhe3etaK7utrBiPBQ2&index=3

Upvotes: 1

Views: 21863

Answers (2)

HusseinAliOfficial
HusseinAliOfficial

Reputation: 1

Solution A

if you are working with python you can use python lib pandas to import your file .csv using:

import pandas as pd
IRIS_TRAINING = pd.read_csv("../iris_training.csv")
IRIS_TEST     = pd.read_csv("../iris_test.csv")

Solution B

import numpy as np
mydata = np.genfromtxt(filename, delimiter=",")

Read More About python-pandas Read More About python-Numpy

Upvotes: -1

AJS
AJS

Reputation: 2023

The issue is that you either need to use file's absolute path i.e C:\path_to_csv\iris_training.csv for windows and for UNIX/Linux /path_to_csv/iris_training.csv or you will need to place the file in your notebook workspace i.e directory that is being listed in your Jupyter UI which can be found at http://localhost:8888/tree Web UI. If you are having trouble finding the directory then just execute below python code and place the file in the printed location

import os
cwd = os.getcwd()
print(cwd)

Upvotes: 4

Related Questions