diff --git a/exercises/02450Toolbox_Python/Scripts/ex1_5_1.py b/exercises/02450Toolbox_Python/Scripts/ex1_5_1.py index d5c7463e0194f997d6ae4e0a1b4825bf6f128b92..41c537339319f104430c2160ecbe9806b0036e4a 100644 --- a/exercises/02450Toolbox_Python/Scripts/ex1_5_1.py +++ b/exercises/02450Toolbox_Python/Scripts/ex1_5_1.py @@ -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. diff --git a/exercises/02450Toolbox_Python/Scripts/ex1_5_2.py b/exercises/02450Toolbox_Python/Scripts/ex1_5_2.py index 7c28d1b6acd79a543adeefcf2e8f0e19d5c3fde8..d421597e4ea9cf2fe4ae18c2dfee4c850f0eca31 100644 --- a/exercises/02450Toolbox_Python/Scripts/ex1_5_2.py +++ b/exercises/02450Toolbox_Python/Scripts/ex1_5_2.py @@ -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 diff --git a/exercises/02450Toolbox_Python/Scripts/ex1_5_3.py b/exercises/02450Toolbox_Python/Scripts/ex1_5_3.py index 97b969279de7da78251f587b795c9368310852a3..cf1fbacb5e0999d0fd9cb89111f385d21b87db22 100644 --- a/exercises/02450Toolbox_Python/Scripts/ex1_5_3.py +++ b/exercises/02450Toolbox_Python/Scripts/ex1_5_3.py @@ -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. diff --git a/exercises/02450Toolbox_Python/Scripts/ex1_5_5.py b/exercises/02450Toolbox_Python/Scripts/ex1_5_5.py index e1b6d01bfdffd2c79772aea93a57c70174359524..4b761a8b36dbcc0e835f20d6b58f3b36b0c90614 100644 --- a/exercises/02450Toolbox_Python/Scripts/ex1_5_5.py +++ b/exercises/02450Toolbox_Python/Scripts/ex1_5_5.py @@ -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