Filtering ESGF datasets versions in the metalink

clear all,fclose all;close all;clc;
nameFile='./hadgem2_es.metalink';
xmlLines=textread(nameFile,'%s','delimiter','\r\n');
endFiles=find(ismember(deblank(xmlLines),{'</file>'}));Nfiles=length(endFiles);
startFiles=[];fileProperties=cell(Nfiles,3);contador=1;
for i=1:length(xmlLines)
    sd=strfind(xmlLines{i},'<file name="');
    if ~isempty(sd)
        startFiles=[startFiles;i];
        fileName=['./' xmlLines{i}(sd+12:end-2)];
        [pathName,fileName,extFile]=fileparts(fileName);
        [aux1,aux2,vFile]=fileparts(pathName);vFile=vFile(2:end);
fileProperties{contador,1}=fileName;fileProperties{contador,2}=vFile;fileProperties{contador,3}=i;
        contador=contador+1;
    end
end
[fileNames,I1,I2]=unique(fileProperties(:,1));
lastFile=cell(length(I1),3);
for i=1:length(I1)
    indFiles=find(I2==i);
versiones=strvcat(fileProperties(indFiles,2));versiones=datenum([str2num(versiones(:,2:5)) str2num(versiones(:,6:7)) str2num(versiones(:,8:9)) repmat([0 0 0],length(indFiles),1)]);
[a1,a2]=max(versiones);lastFile(i,:)=fileProperties(indFiles(a2),:);
end
fid=fopen([nameFile '_last_version.metalink'],'w');
for i=1:min(startFiles)-1
    fprintf(fid,'%s \r\n',xmlLines{i});
end
Nfiles=length(I1);
for i=1:Nfiles
    indFile=find(startFiles==lastFile{i,3});
    for j=startFiles(indFile):endFiles(indFile)
        fprintf(fid,'%s \r\n',xmlLines{j});
    end
end
for i=max(endFiles)+1:length(xmlLines)
    fprintf(fid,'%s \r\n',xmlLines{i});
end
fclose(fid); 

Attachments (1)

Download all attachments as: .zip

Comments

1. Colin -- 2017-09-25 14:00

Hello, this is fastidious post I actually loved reading this. https://foammarker.net

2. Lousi feocy -- 2017-10-18 20:22

Found your blog excessively interesting indeed. I really enjoyed studying it. https://crossfitsite.com/

3. Rey Johnson -- 2017-10-18 21:09

No wonder why you receive countless of feedbacks https://www.gympros.com/ .

4. anonymous -- 2017-10-20 07:50

Even if you’ve tried everything you can think of to get traffic and failed to convert it, you CAN with Click Funnels! We have members making millions of dollars in sales without spending one dime on advertising, using our powerful conversion tools like built-in split-testing, order form bumps, countdown timers, and more at http://clickfunnelsreview.net

5. rOBERT -- 2017-10-21 12:29

Writers per hour will look into your background and compose a statement which will fulfill your dreams. Capstone Paper- often students ask, someone write my project paper, and Our answer is, of course we can. We will write your project in a way that you will get to learn allot from it and will also get the best grade….. https://www.yellowpages.com/newark-nj/mip/writers-per-hour-custom-writing-service-520720565

6. clickfunnels review -- 2017-10-24 09:03

Hey to everyone, it’s my first visit of the blog site; this blog includes awesome and actually best info for the visitors. http://clickfunnelsreview.net/

7. Ron -- 2017-10-26 09:16

So this will make it easier for people to get the savings they need to have and know the sales are going to continue to give them the income at https://www.ritewik.com/…..

8. ADELAIDE -- 2017-11-06 16:22

Superb way of explaining, and great blog to get wonderful information. http://www.outdoorlivinggear.com/what-is-the-best-propane-smoker/

9. anonymous -- 2017-11-18 07:06

You fully match our expectation and the selection of our data. https://online-casino-osterreich.at

10. top retina specialist in pune -- 2017-11-24 08:03

top retina specialist in pune - Atharva Netralaya is one of best team of eye specialist in pune, we have more than 56 eye specialist under one roof to know more visit us on ​http://www.atharvanetralaya.com/best-eye-hospital-in-pune/top-retina-specialist-in-pune/

11. http://www.pmmarketer.com/ -- 2017-11-27 10:54

You create sense out of the foremost complex topics. http://www.pmmarketer.com/

12. sofia123jas@… -- 2017-11-30 09:46

I love all details that you give in your articles. <a href="https://migliorcasinoonlinesicuri.it">migliorcasinoonlinesicuri.it</a>

13. anonymous -- 2017-12-04 13:07

I concede, I have not been on this site page in quite a while... be that as it may it was another delight to see It is such a vital subject and overlooked by such a variety of, even experts. experts. I thank you to help making individuals more mindful of conceivable issues. [url=https://bitcoingeardepot.com/collections/bitcoin-sweatshirts]Bitcoin Sweatshirtsurl

14. anonymous -- 2017-12-16 14:13

No doubt why you get so many blog comments. Jamtogel Togel Singapura http://www.jamtogel.com/

15. internet Marketing Calgary -- 2017-12-19 13:28

Hey to everyone, it’s my first visit of the blog site; this blog includes awesome and actually best info for the visitors. <a href="https://sites.google.com/calgaryseocompany.ca/calgary-seo">calgary Internet marketing</a>

16. internet Marketing Calgary -- 2017-12-19 13:29

Hey to everyone, it’s my first visit of the blog site; this blog includes awesome and actually best info for the visitors. https://sites.google.com/calgaryseocompany.ca/calgary-seo

17. anonymous -- 2017-12-20 10:32

Waooow!!! Magnificent blogs, this is what I wanted to search. Thanks buddy <a href="https://sites.google.com/calgaryseocompany.ca/calgary-seo">calgary seo</a>

18. SAMS -- 2017-12-20 12:18

Keep up the best work guys, nice posts are here to get more benefits. http://www.geeknode.co.za/2016/10/press-release-rage-your-glimpse-into-whats-trending-across-the-globe/

19. Morone -- 2017-12-20 12:19

I have visited lots of the blogs but this blog is truthfully wonderful. David

20. anonymous -- 2018-01-02 09:29

Every week-end I used to pay a fast visit this site, because I’d like enjoyment, because this web site conations certainly fussy material. https://ceske-casino-online.cz/

21. anonymous -- 2018-03-21 07:50

In this state getting support with your exposition is simply what the understudies require. Getting back into a bad situation! These expositions are justified regardless of an expansive area of your evaluation list and get tallied to make your report card. Normally the understudies oversee presenting the expositions, yet get normal evaluations and when the work heaps up they lose that as well.

http://estrelasdepinhel.com

22. Davielle4 -- 2018-05-29 10:05

Filter ESGF datasets versions.

gmail sign up help. Spanish dictionary

23. shawnjasper -- 2018-06-02 13:20

I recently came across your blog and have been reading along. https://www.theacademicpapers.co.uk/dissertation-proposal-writing-service.php I think it’s a well informatics written post. Its shows the written quality of writer. Welldone friend keep it up..

Add New Comment