skip to Main Content

I am trying to open a .MAT file the file name is MNIST.mat and it is located in following folder
/home/debian/cs640 machine learning/assignment5
here is a script which I wrote following some search on internet what I want to do is open the file and save it as excel

#!/usr/bin/python3
import os
from mat4py import loadmat
os.getcwd()
mat=loadmat('/home/debian/cs640 machine learning/assignment5MNIST.mat')
print (mat)

~

but currently I am getting error

Traceback (most recent call last): File “./script1.py”, line 5, in

mat=loadmat(‘/home/debian/cs640 machine learning/assignment5MNIST.mat’) File
“/home/debian/.local/lib/python3.7/site-packages/mat4py/loadmat.py”,
line 417, in loadmat
fd = open(filename, ‘rb’) FileNotFoundError: [Errno 2] No such file or directory: ‘/home/debian/cs640 machine
learning/assignment5MNIST.mat’

so why is this error coming in my program?

2

Answers


  1. The program is not able to find the file. check the path or name of the file.
    you have space in your directory name cs640 machine learning. change it to cs640_machine_learning. It might work.

    Login or Signup to reply.
  2. You are mixing up Unix and DOS directory separators. You are using Linux, which uses Unix-style / for directory separators. Windows used the DOS-style for directory separators. Your file location has a mix of both. Just change:

    'assignment5MNIST.mat'
    

    To

    'assignment5/MNIST.mat'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search