Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Need help with local_csv() in Research

I am trying to read a CSV file using local_csv() in Research:

data = local_csv('/Users/Desktop/FRED-DGS3MO.csv', date_column='Date')  

Repeated attempts failed with errors:

IOErrorTraceback (most recent call last)
in ()
----> 1 data = local_csv('/Users/Desktop/FRED-DGS3MO.csv', date_column='Date')
2 data.head()

/build/src/qexec_repo/qexec/research/api.py in local_csv(path,
symbol_column, date_column, use_date_column_as_index, timezone,
symbol_reference_date, *read_csv_kwargs)
286 symbol_reference_date=symbol_reference_date,
287 symbols_function=symbols,
--> 288 *
read_csv_kwargs
289 )
290

/build/src/qexec_repo/qexec/research/api.pyc in inner_local_csv(path,
symbol_column, date_column, use_date_column_as_index, timezone,
symbol_reference_date, symbols_function, **read_csv_kwargs)
823 if not realpath.startswith(NOTEBOOK
DATA_DIR):
824 raise IOError(
--> 825 "Cannot open file {path}.".format(path=path)
826 )
827

IOError: Cannot open file /Users/Desktop/FRED-DGS3MO.csv.

CSV data in 2 columns:

Date, Value  
2017-08-31, 1.01  
2017-08-30, 1.03  
2017-08-29, 1.03  
2017-08-28, 0.98  
2017-08-25, 1.03  
2017-08-24, 1.02  

Not sure what I have missed.. please help?

Thanks,

Karl

1 response

Hi Karl,

Try uploading the file to the /data directory from the Notebooks page. (In case you haven't used the file upload in research, click on Notebooks -> the 'data' folder -> the 'upload file' button on the top right).

local_csv reads in files from the /data directory, so once you have your file in that directory, it should be readable. You'd also need to modify your invocation of local_csv, to something like:

data = local_csv('FRED-DGS3MO.csv', date_column='Date')  
Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.