Save a String as a Csv

20 ビュー (過去 30 日間)
Joshua
Joshua 2016 年 1 月 4 日
コメント済み: Walter Roberson 2016 年 1 月 5 日
I'm trying to save and stockdata from yahoo finance.
% code
Quotes = urlread('http://real-chart.finance.yahoo.com/table.csv?s=HMSY&a=00&b=1&c=2015&d=00&e=4&f=2099&g=d&ignore=.csv');
"Quotes" will end up being a string in csv form. How can I save "Quotes" as a .csv file?
Edit: I posted the wrong string in urlread by accident.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 1 月 4 日
No it will not. Given that URL, Quotes will end up being a string full of HTML that does not contain the data at all, and instead contains references to javascript functions that presumably read in the data.
  2 件のコメント
Joshua
Joshua 2016 年 1 月 4 日
Sorry about that, I copied and pasted the wrong URL. That has been corrected.
Walter Roberson
Walter Roberson 2016 年 1 月 5 日
To store that as a csv file:
fid = fopen('YourFile.csv', 'wt');
fwrite(fid, Quotes);
fclose(fid);
If you had wanted it as an xls* file then there would have been more work, but since it is already in csv line structure just write the string to a file.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by