How do I export this file i downloaded to a separate file on my desktop?

1 回表示 (過去 30 日間)
Laurentiu Galan
Laurentiu Galan 2011 年 11 月 12 日
Hi,
I've just started using Matlab and was wondering if someone could help me with finishing up this code.
Basically I am trying to download a file from yahoo finance and export it to a file. How do I create a saved file containing my downloaded data in an output folder which is in C:\Users\Desktop\ It's something with the fwrite function, but i can't figure it out. Thanks a lot,
thissym='IBM';
thisurl = strcat('http://ichart.finance.yahoo.com/table.csv?s=', thissym, '&d=10&e=8&f=2011&g=d&a=0&b=1&c=2000&ignore=.csv')
thisdata=urlread(thisurl);
thisfilename = strcat(thissym, '.csv')
thisfileid=fopen(thisfilename, 'w')
fwrite(thisfileid, thisdata)
fclose(thisfileid)

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 12 日
thisfileid=fopen(thisfilename, 'wt')
fprintf(thisfileid, '%s\n',thisdata)
fclose(thisfileid);

その他の回答 (1 件)

Laurentiu Galan
Laurentiu Galan 2011 年 11 月 12 日
This helps, but how do I save thisurl to a separate .csv file on my desktop.
Thanks!
  2 件のコメント
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 12 日
Use the same code above, just change the file name, replace thisdata with thisrul.
Laurentiu Galan
Laurentiu Galan 2011 年 11 月 12 日
Figured it out. Cheers!

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

カテゴリ

Help Center および File ExchangeFinancial Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by