creating a file and inserting comma separated data in loop

2 ビュー (過去 30 日間)
Damian
Damian 2014 年 7 月 21 日
Hello, I have a function which open up a folder, read all the data to variables in loop ( open one file at the time, read all the data from it ), and I want to write all extracted data in new CSV file.
function quote = readfolder()
list = dir(strcat('G:\results\')
no_files = size(list)
disp(no_files)
for i= 1:no_files(1,1)-2
url = strcat('G:\results\','FILE_NR=', '.', int2str(i), '.html') ;
html = fileread(url) ;
% url, html, its just from previous modifications
% below - just reading variables from my html file.
Summary = regexp( html, 'Summary:.*?">([^<]+)', 'tokens', 'once' )
ti_ultimate_osc__value = regexp( html, 'Oscillator <.*?id="open_9">([\-+\d\.]+)', 'tokens', 'once' )
ma200_simple = regexp( html, 'MA200.*?[\-+\d\.]+.*?">([^<]+)', 'tokens', 'once' )
% This is where I should write to file I guess.
end
end
I want to create (or overwrite old) CSV file before the loop begins; and insert new data Summary, ti_ultimate_osc__value, ma200_simple (one line in CSV for each html file in folder while loop reads the files).
I made several tries, no good results, please help move in a right direction
PS: I deleted bits from my file to make it short. Everything should still be fine.

回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by