Issue with genfromtxt

211 views Asked by At

I am relatively new to coding and I wanted to try my hand at building code to back-test data, but I am having some issue with extracting a column from my data into a numpy array. Below I have screen shots of how I want it to be formatted and the issues I am running into. Any help would be appreciated.

import numpy 
import talib
from numpy import genfromtxt

my_data = genfromtxt('1_DAY.csv', delimiter=",")

print(my_data)

close = my_data[:,4]

print(close)

(https://i.stack.imgur.com/g7rm4.png)

But I keep getting this output...

PS C:\Users\Namaste\Documents\GitHub\binance-tutorials\coinview> conda activate base

PS C:\Users\Namaste\Documents\GitHub\binance-tutorials\coinview> & C:/Users/Namaste/Anaconda3/python.exe

C:/Users/Namaste/Documents/GitHub/binance-tutorials/coinview/ta.py Traceback (most recent call last):

File "c:/Users/Namaste/Documents/GitHub/binance-tutorials/coinview/ta.py", line 5, in my_data = genfromtxt('1_DAY.csv', delimiter=",")

File "C:\Users\Namaste\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1749, in genfromtxt fid = np.lib._datasource.open(fname, 'rt', encoding=encoding)

File "C:\Users\Namaste\Anaconda3\lib\site-packages\numpy\lib_datasource.py", line 195, in open return ds.open(path, mode, encoding=encoding, newline=newline)

File "C:\Users\Namaste\Anaconda3\lib\site-packages\numpy\lib_datasource.py", line 535, in open raise IOError("%s not found." % path)

OSError: 1_DAY.csv not found. (https://i.stack.imgur.com/JERv3.png)

But I am trying to get the data to look like this... (https://i.stack.imgur.com/QvNvu.png)

I've read online that pandas is better for csv file but I am using TA-Lib and it uses numpy to build arrays.

0

There are 0 answers