I hope this is an okay place for this question, I've already finished the Python course, but I just wanted to ask a more detailed question about file input.
BACKGROUND: I have a Python project (see below) which turns a series of strings into two columns of numbers for data analysis. The code works perfectly, but only works on files that are in the same folder as my Python file.
Is there a way to input the file from another folder? At the moment I have to move each .dat file to the folder containing my .py file, but it would be nicer to keep my .dat files where they are and still be able to input them into my code.
results = open('data.dat', 'r') temp =  for item in results: x = item.split() y= item.split() y = y[1:] if float(x) <= -0.8 and float(x) >= -0.95: temp.append(y) results.close()
Hope someone can help.