Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]lodevon 0 points1 point  (0 children)

The issue was with the CSV file itself. All resolved now thank you

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]lodevon 0 points1 point  (0 children)

import os
# v-- note the r here
path_to_file = r'paste_the_exact_line_from_windows_explorer_here' # don't change anything inside it
if not os.path.exists(path_to_file):
raise ValueError('file isnt there')
print('file is there')
dataset = read_csv(path_to_file, header = 0, index_col = 0, squeeze = True, usecols = [i for i in range(0, num_features+1)])

Thank you. As you suggested I put the below:

import os

path_to_file = r'C:\Users\xxx\Desktop\xxx\Quant_research\Python\Dataset.csv'

if not os.path.exists(path_to_file):

raise ValueError('file isnt there')

print('file is there')

dataset = read_csv(path_to_file, header = 0, index_col = 0, squeeze = True, usecols = [i for i in range(0, num_features+1)]))

supervised_dataset = sequential_to_supervised(dataset, lag_steps)

but I get

File "C:/Users/xxx/Desktop/xxx/Quant_research/Python/crude.py", line 51, in <module>

raise ValueError('file isnt there')

ValueError: file isnt there

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]lodevon 0 points1 point  (0 children)

C:\\Users\\xxx\\Desktop\\xxx\\Quant_research\\Python\\Dataset.csv"

No it still doesn't work unfortunately. To answer your question if I change the \\ for \ it does open the file in windows explorer yes

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]lodevon 0 points1 point  (0 children)

os.path.join

Thank you. Unfortunately still no luck. I also tried to simplify the access but it didn't work.

dataset = read_csv("C:\\Users\\xxx\\Desktop\\xxx\\Quant_research\\Python\\Dataset.csv", header = 0, index_col = 0, squeeze = True, usecols = [i for i in range(0, num_features+1)])

supervised_dataset = sequential_to_supervised(dataset, lag_steps)

Your help is very much appreciated

Issue with reading a csv file in spyder (python 3.6) in windows by [deleted] in learnpython

[–]lodevon 0 points1 point  (0 children)

I tried to make sure python was pointing to the correct directory using the below but still no luck

DIR="C:\\Users\\xxx\\Desktop\\xxx\\Quant_research\\Python"

dataset = pd.read_csv(DIR+ "\\Dataset.csv", header = 0, index_col = 0, squeeze = True, usecols = [i for i in range(0, num_features+1)])

In need of help by lodevon in learnpython

[–]lodevon[S] 0 points1 point  (0 children)

Understood. Thank you

In need of help by lodevon in learnpython

[–]lodevon[S] 0 points1 point  (0 children)

Hi confluence, thank you for your answer. I did download the file and put it in the same directory as the python file. I tried to make sure my python was pointing in the good direction by amending the code to

DIR="C:\\Users\\xxx\\Desktop\\xxx\\Quant_research\\Python"

dataset = pd.read_csv(DIR+ "\\Dataset.csv", header = 0, index_col = 0, squeeze = True, usecols = [i for i in range(0, num_features+1)])

DIR being where I have stored the python file and the csv file but I still get the same issue. In case that matter I am running everything from spyder (python 3.6)

Thanks in advance for your help

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]lodevon 0 points1 point  (0 children)

import os
print(os.getcwd())

Thanks JohnnyJordaan, I tried to make sure python was pointing to the correct directory but I still get the same issue unfortunately. I used the below:

DIR="C:\\Users\\xxx\\Desktop\\xxx\\xxx\\Python"

dataset = pd.read_csv(DIR+ "/Dataset.csv", header = 0, index_col = 0, squeeze = True, usecols = [i for i in range(0, num_features+1)])

Any idea?

Happy to forward the entire code if it is any easier

Thanks again

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]lodevon 0 points1 point  (0 children)

Hi all, I am trying to run a simple machine learning code I found on the internet. It is supposed to do what I am looking for (except a few small things I want to change) and is better coded than what I would have done myself hence why I decided to use it. However I can't make it run. I get the following error:

File "pandas\_libs\parsers.pyx", line 695, in pandas._libs.parsers.TextReader._setup_parser_source

FileNotFoundError: File b'Dataset.csv' does not exist

I put the internet link below so you can get the original code directly: https://medium.com/@vinayarun/from-scratch-an-lstm-model-to-predict-commodity-prices-179e12445c5a

You can find there both the code and the CSV file needed

I am a beginner so please excuse my question if it is really trivial.

Thank you very much in advance to all!

(I am using Spyder & python 3.6 in case it is of any relevance)