Skip to content
Snippets Groups Projects
Commit b264f4a3 authored by bjje's avatar bjje
Browse files

Print the data file location in ex1.5.1-1.5.3,1.5.5

parent 77f8c6f8
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,12 @@ import pandas as pd
# Load the Iris csv data using the Pandas library
filename = importlib_resources.files("dtuimldmtools").joinpath("data/iris.csv")
# Print the location of the iris.csv file on your computer.
# You should inspect it manually to understand the format and content
print("\nLocation of the iris.csv file: {}".format(filename))
# Load the iris.csv file using pandas
df = pd.read_csv(filename)
# Pandas returns a dataframe, (df) which could be used for handling the data.
......
......@@ -11,11 +11,15 @@ import xlrd
# data to excel files, see the following tutorial:
# http://www.simplistix.co.uk/presentations/python-excel.pdf}
# Load xls sheet with data
# There's only a single sheet in the .xls, so we take out that sheet
# Get path to the datafile
filename = importlib_resources.files("dtuimldmtools").joinpath("data/iris.xls")
# Print the location of the iris.xls file on your computer.
# You should inspect it manually to understand the format and content
print("\nLocation of the iris.xls file: {}".format(filename))
# Load xls sheet with data
# There's only a single sheet in the .xls, so we take out that sheet
doc = xlrd.open_workbook(filename).sheet_by_index(0)
# Extract attribute names
......
......@@ -7,10 +7,16 @@ from scipy.io import loadmat
# The matlab workspace is loaded as a dictionary, with keys corresponding to
# matlab variable names, and values to arrays representing matlab matrices.
# Load Matlab data file to python dict structure
# Get path to the datafile
filename = importlib_resources.files("dtuimldmtools").joinpath("data/iris.mat")
# Print the location of the iris.mat file on your computer.
# You should inspect it manually to understand the format and content
print("\nLocation of the iris.mat file: {}".format(filename))
# Load Matlab data file to python dict structure
iris_mat = loadmat(filename, squeeze_me=True)
# The argument squeeze_me ensures that there the variables we get from the
# MATLAB filed are not stored within "unneeded" array dimensions.
......
......@@ -9,7 +9,13 @@ import pandas as pd
# We start by defining the path to the file that we're we need to load.
# Upon inspection, we saw that the messy_data.data was infact a file in the
# format of a CSV-file with a ".data" extention instead.
filename = importlib_resources.files("dtuimldmtools").joinpath("data/messy_data/messy_data.data")
foldername = importlib_resources.files("dtuimldmtools").joinpath("data/messy_data")
filename = foldername.joinpath("messy_data.data")
# Print the location of the messy_data folder and file.
# You should inspect it manually to understand the format and content
print("\nLocation of the messy_data folder: {}".format(foldername))
print("\nLocation of the messy_data.data file: {}\n".format(filename))
# First of we simply read the file in using readtable, however, we need to
# tell the function that the file is tab-seperated. We also need to specify
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment