Trouble saving Table to CSV file in Version 13

For questions regarding programming in the EViews programming language.

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

MCD_nz
Posts: 7
Joined: Fri May 17, 2019 2:45 pm

Trouble saving Table to CSV file in Version 13

Postby MCD_nz » Tue May 16, 2023 10:46 pm

I am trying to save a table (with a date stamp) as a CSV file

The commands are
%date="c:\w1\jp_forecasts_"+@strnow("yyyy-mm-dd")
jp_table.save(t=csv) {%date}

These commands works in Version 12 but deliver the following error message in Version 13

Error message is :
Unable to open file c:\w1.csv in "JP_TABLE.SAVE(T=CSV)
C:\W1\JP_FORECASTS_2023-5-17" in FAN_JP.PRG on line 194.

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

Re: Trouble saving Table to CSV file in Version 13

Postby EViews Gareth » Wed May 17, 2023 8:39 am

What is jp_table?
Follow us on Twitter @IHSEViews

MCD_nz
Posts: 7
Joined: Fri May 17, 2019 2:45 pm

Re: Trouble saving Table to CSV file in Version 13

Postby MCD_nz » Wed May 17, 2023 3:24 pm

Sorry.
jp_table is a TABLE object. Created using the commands:

group fcst num1 num2 num3
freeze(jp_table) fcst

'create string for file name path (with date stamp)
%date="c:\w1\jp_forecasts_"+@strnow("yyyy-mm-dd")

'saving Table to CSV file
jp_table.save(t=csv) {%date}

MCD_nz
Posts: 7
Joined: Fri May 17, 2019 2:45 pm

Re: Trouble saving Table to CSV file in Version 13

Postby MCD_nz » Wed May 17, 2023 6:51 pm

Perhaps I should have put this in the 'bugs' category.

The problem seems to be when there is a <space> in the proposed file name.

In the following test program:
a file called TEST.csv is saved in the "0_work" directory when Version 13 is run
a file called FORECASTS_2023_5_18.csv is saved in the "0_work\test forecasts" directory when Version 12 is run (desired outcome)
(a file name with multiple <space> characters causes the program to crash in Version 13).

%runpath = @runpath
cd %runpath
wfcreate(wf=tble_test, page=trial) u 1 10
series num1 = rnd
series num2 = rnd
series num3 = rnd
group fcst num1 num2 num3
freeze(jp_table) fcst
%date="c:\0_work\test forecast\forecasts_"+@strnow("yyyy-mm-dd")
jp_table.save(t=csv) {%date}

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

Re: Trouble saving Table to CSV file in Version 13

Postby EViews Gareth » Wed May 17, 2023 7:42 pm

What happens if you use:

Code: Select all

jp_table.save(t=csv) %date
Follow us on Twitter @IHSEViews

MCD_nz
Posts: 7
Joined: Fri May 17, 2019 2:45 pm

Re: Trouble saving Table to CSV file in Version 13

Postby MCD_nz » Wed May 17, 2023 9:26 pm

That solution works. Thank you.


Return to “Programming”

Who is online

Users browsing this forum: Google [Bot] and 25 guests