Hello,
I am new to the platform and I am importing one of my favorite strategy that lays on a .csv file (4.5 MB): I could not open it from the project then I try to open it from my personnal server by doing these lines:
file = self.Download("http://my_ip_address/share/file.csv")
self.combination_info = pd.read_csv(file)
The strategy crashes and give me this error: During the algorithm initialization, the following exception has occurred: [Errno 36] File name too long: '[the whole content of my file]'
How can I use my .csv in my project with out any issue with QuantConnect?
Mia Alissi
Hello Adrien,
The error you're encountering is because the
self.Download()
method returns the content of the file as a string, not the file itself. When you try to pass this string content directly topd.read_csv()
, it's interpreting the entire content of your file as a file name, hence the "File name too long" error.Here's how you can correctly load your CSV file:
This code first downloads the content of your CSV file as a string, then uses
StringIO
to convert this string into a file-like object thatpd.read_csv()
can read.Please note that if your CSV file is too large, you might encounter issues due to memory limitations. In such cases, you might need to consider splitting your data into smaller files or using a different data storage solution that doesn't have such limitations. For more details, you can refer to the QuantConnect Documentation.
Also, please be aware that due to data licensing agreements, exporting data isn't allowed on QuantConnect unless it is a tiny volume of data (less than 10kb) source.
I hope this helps! Let me know if you have any other questions.
Sources:
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Adrien Aubourg
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!