creating a file and inserting comma separated data in loop
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!