Page 1 of 1

File IO Failed

Posted: Fri Oct 05, 2018 3:55 am
by dhityayl
I have a code for loop programming below. So basically i loop a rolling regression and after that i want to save to excel.
The code below works for the looping itself (without wfsave), but in the middle of the looping with wfsave, the loop failed. The error message is : File IO failed for file 'Could not create entry in zip file.' in "WFSAVE(TYPE=EXCELXML) "C:\USERS\DHITYA\DESKTOP\2\2001.T.CSV.XLSX" @KEEP DATE RETURN G1".
Is there something wrong with the code? It works before with just 2 files, but when i do 50 files, it failed.
If i want to try running the program again with different data, i should create a new destination folder to save my file, but it will failed again in the middle of the loop.

Code: Select all

cd "D:\Thesis_Loop\2002_2\dataset"
%filenames = @wdir("D:\Thesis_Loop\2002_2\dataset")
for !k=1 to @wcount(%filenames)
   %file = @word(%filenames, !k)
   wfopen %file
   import D:\Thesis_Loop\2002_2\dataset\index\Indeks_2002.csv
   import D:\Thesis_Loop\2002_2\dataset\index\FF3_2002.csv
   genr return=(((close-close(-1))/close(-1))*100)-rf   
!window = 60
   !step = 1
   !length = @obsrange
   equation eq1
   !nrolls = @round((!length-!window+1)/!step)
   matrix(5,!nrolls) coefmat!k
      for !i = 1 to !length-!window+1-!step step !step
      smpl @first+!i-1 @first+!i+!window-2
      equation return c indeks mkt_rf smb hml
      colplace(coefmat!k, eq1.@coefs,!j)
      matrix(!nrolls,5) r1
      matrix r1=@transpose (coefmat!k)
         series rbc
         series rbindeks
         series rbmkt
         series rbsmb
         series rbhml
         group g1 rbc rbindeks rbmkt rbsmb rbhml
         sample s1 @first+59 @last
         mtos(r1, g1, s1)
            if @isobject("s1") then
            delete s1
%path = "C:\Users\Dhitya\Desktop\2\" + %file + ".xlsx"
wfsave(type=excelxml) %path @keep date return g1

   'close @all


Re: File IO Failed

Posted: Fri Oct 05, 2018 8:57 am
by EViews Jason
Is it failing on the same file every time (i.e. does the error message always refer to C:\USERS\DHITYA\DESKTOP\2\2001.T.CSV.XLSX)?

Can you post the list of filenames in the C:\USERS\DHITYA\DESKTOP\2 directory?

Re: File IO Failed

Posted: Fri Oct 05, 2018 3:27 pm
by dhityayl
Hi. It works fine on other computer. I think the problem is not on the eviews program.
Thank you

Re: File IO Failed

Posted: Wed Oct 10, 2018 7:21 am
by EViews Jason
I would then verify all the paths and files that are being referred to in your program exist. For example, make sure C:\USERS\DHITYA\DESKTOP\2\ and D:\Thesis_Loop\2002_2\dataset\index\ exist.