Data-Analysis icon indicating copy to clipboard operation
Data-Analysis copied to clipboard

Load from local CSV

Open asfolcini opened this issue 7 years ago • 4 comments
trafficstars

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

asfolcini avatar Jun 01 '18 11:06 asfolcini

Perhaps consider an adapter pattern here (ie QuandlSourceAdapter / CustomSourceApdapter ). It will provide extensible way of adding datasources for the library. What do you think ?

uriencedric avatar Jun 05 '18 13:06 uriencedric

Sorry I can't use it from local csv to run. Can you give me an example? THX

skyking363 avatar Jul 20 '18 14:07 skyking363

open a PR with the changes requested

kevb10 avatar Jun 24 '19 00:06 kevb10

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.

Rohan1280 avatar Jun 09 '20 20:06 Rohan1280