My teacher put up a large data in the school server and gave me a piece of code to open up the files. Below is my code:
import sys
sys.path.append("/Data/Data123/.local/lib/python2.7/site-packages")
from cloud.common import get_tile
from scipy.io import netcdf_file as copen
from scipy import interpolate
import matplotlib
from matplotlib import pyplot as pp
import matplotlib.cm as cm
import numpy
path = '/Data/a'
filenames = ['Hello.nc']
But when I run the code, it says there is “No such file or directory :’Hello.nc’
I am sure files are in that directory. So I want to ask, what did I do wrong?
Or am I not even collecting to the directory?
Thanks
It would be very difficult to answer this question without knowing what files are on the server and also looking at the code that actually connects, and attempts to retrieve the file; but I can provide you with this suggestion.
Use
os.pathinstead of declaring a literal path string. For example:Change:
To:
Then, when you concatenate
pathwith a filename, useos.path.joinagain:The problem may be in the way you combine
pathwith a filename. If this does not help, please add more code or double check the server to make sure the file is there.