Looping through files in a folder

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

mike_d
Posts: 17
Joined: Thu Feb 09, 2012 7:52 am

Looping through files in a folder

Postby mike_d » Mon Feb 13, 2012 1:07 pm

Hi, I am new to eviews and am simply trying to execute a peice of code on various files. I cannot seem to figure out how to properly insert the for loop number into the wfopen statement. I can open each file on its own by writing the full pathname out so that is not my problem. I have tried to create a matrix that is filled with the value 'i' on each loop (1 to 6 in this case) and could not get that to work either. I have posted my most recent attempt. Any guidance would be greatly appreciated.



cd \\Client\E$\Database
wfcreate (wf = issue) u 3131

for !i = 1 to 6
matrix(6,1) issue_num
issue_num(!i,1) = @str(!i)

wfopen "\\Client\E$\Database\Bond" + @str(!i) + ".xlsx" '' not working
freeze(uroottest_cds_spread) cds_spread.uroot(adf,const)
freeze(uroottest_FITCH_RATE ) FITCH_RATE .uroot(adf,const)
freeze(descriptives_CDS) CDS_SPREAD.stats
freeze(descriptives_Fitch) FITCH_RATE.stats

'''save results




next

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Looping through files in a folder

Postby EViews Gareth » Mon Feb 13, 2012 1:46 pm

You can't build the full file name up as part of the wfopen command. Build it up in a temporary string first then use that temp string in wfopen.

mike_d
Posts: 17
Joined: Thu Feb 09, 2012 7:52 am

Re: Looping through files in a folder

Postby mike_d » Mon Feb 13, 2012 1:55 pm

Thanks so much for the speedy reply. Only took a few minutes to figure out exactly how to do that. Thanks again!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest