Data-Analysis
Data-Analysis copied to clipboard
Load from local CSV
Hi there,
Pls consider to load data from local CSV.
`
# Initialization requires a ticker symbol
def __init__(self, ticker, exchange='WIKI', csv_repository=""):
# Enforce capitalization
ticker = ticker.upper()
# Symbol is used for labeling plots
self.symbol = ticker
# Use Personal Api Key
#quandl.ApiConfig.api_key = 'xxxxxxxxxxxxxxxxxxxxxxxx'
if exchange in "CSV":
print("Load from CSV file...")
stock = pd.read_csv(self.symbol_to_path(ticker,csv_repository), index_col='Date',
parse_dates=True,
# usecols=['Date', 'Open','High','Low','Adj Close','Volume'],
na_values=['nan'])
#print(stock.head(5))
else:
# Retrieval the financial data from QUANDL
try:
stock = quandl.get('%s/%s' % (exchange, ticker))
except Exception as e:
print('Error Retrieving Data.')
print(e)
return
... `
Check my modified version here: https://github.com/asfolcini/stocker/blob/master/stocker.py
Perhaps consider an adapter pattern here (ie QuandlSourceAdapter / CustomSourceApdapter ). It will provide extensible way of adding datasources for the library. What do you think ?
Sorry I can't use it from local csv to run. Can you give me an example? THX
open a PR with the changes requested
Sorry I can't use it from local csv to run. Can you give me an example? THX
df=pd.read_csv(r'C:\Users\Rohan\Desktop\ML\linear_ref_multivariate\homeprices.csv') @just add r before file location...After adding r, represents raw data.so u will not get any error after adding r.