Import several xls or csv files
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
Creditevent
- Posts: 6
- Joined: Mon Oct 11, 2010 12:18 pm
Import several xls or csv files
Eviews 6:
I would like to import several (30) xls or csv files into Eviews (each having one work sheet). The variables in the xls or csv data files are the same. I would like data in one large Eviews work file. Alternatively, is it easier if I combine the many xls files into one file with serveral work sheets before importing them in Eviews?
I would like to import several (30) xls or csv files into Eviews (each having one work sheet). The variables in the xls or csv data files are the same. I would like data in one large Eviews work file. Alternatively, is it easier if I combine the many xls files into one file with serveral work sheets before importing them in Eviews?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13602
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Import several xls or csv files
In EViews 6 your options are quite limited. However you could write a program that will read in the 30 files into separate pages in a workfile, then copy all the data from the separate pages into one big page.
-
Creditevent
- Posts: 6
- Joined: Mon Oct 11, 2010 12:18 pm
Re: Import several xls or csv files
Thank you for the answer. If I just import each seperately and use "proc" "append to current page" -> do you know whether Eviews then keeps the right structure in the data?
In EViews 6 your options are quite limited. However you could write a program that will read in the 30 files into separate pages in a workfile, then copy all the data from the separate pages into one big page.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13602
- Joined: Tue Sep 16, 2008 5:38 pm
Import several xls or csv files
Try it :)
Re: Import several xls or csv files
I have problems with importing several csv files. I was going to make a post, but this forum does not allow me to upload csv file. Why is it so? Wouldn't be more natural to just attach the file instead of desribing the structure?
Re: Import several xls or csv files
I want to import several (30) csv files. Files are named 1.csv, 2.csv,... 1 file represents data of one stock. Actually, I want to import one csv file, do some calculations (estimate GARCH model), keep the results, import another file, do the same calculations again, keep the results, etc.
The file looks like this:
DATE,TICKER,PERMNO,BIDLO,ASKHI,PRC,VOL,RET,BID,ASK,CFACPR,OPENPRC,RETX
19920615,AXP,59176,23.37500,23.75000,23.62500,1138800,0.000000,,,3.8546586,23.50000,0.000000
19920616,AXP,59176,23.25000,23.87500,23.25000,2033800,-0.015873,,,3.8546586,23.62500,-0.015873
...
Using this forum, I manage to put together code for estimation and rolling forecast of a GARCH model:
!length = @obsrange
!estimation_window = 500
Afterwards, I will evaluate forecasts using: http://forums.eviews.com/viewtopic.php?f=15&t=835
I tried, and I can import the data manually, but I want to import it using eviews code. Later I will do similar calculations over and over.
I want to import the file in such a way that eviews understand that:
1. "DATE" is a date.
2. I can potentially not import some of the culomns, e.g. "TICKER", "PERMNO".
thank you
Peter
The file looks like this:
DATE,TICKER,PERMNO,BIDLO,ASKHI,PRC,VOL,RET,BID,ASK,CFACPR,OPENPRC,RETX
19920615,AXP,59176,23.37500,23.75000,23.62500,1138800,0.000000,,,3.8546586,23.50000,0.000000
19920616,AXP,59176,23.25000,23.87500,23.25000,2033800,-0.015873,,,3.8546586,23.62500,-0.015873
...
Using this forum, I manage to put together code for estimation and rolling forecast of a GARCH model:
!length = @obsrange
!estimation_window = 500
Code: Select all
for !i=estimation_window to length-2
smpl @first+!i-estimation_window @first+!i
equation kamo.ARCH(1,1) retx
smpl @first+!i+1 @first+!i+1
kamo.forecast r se var
malickykamo(!i+2)=var(!i+2)
nextI tried, and I can import the data manually, but I want to import it using eviews code. Later I will do similar calculations over and over.
I want to import the file in such a way that eviews understand that:
1. "DATE" is a date.
2. I can potentially not import some of the culomns, e.g. "TICKER", "PERMNO".
thank you
Peter
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13602
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Import several xls or csv files
You can probably just use WFOPEN to open the file in EViews. It will probably work everything out automatically.
I've just enabled csv attachments.
I've just enabled csv attachments.
Re: Import several xls or csv files
Here is the attachment.
When I use "wfopen 1.csv", then the window "text read - step 1 of 4" pops up. Here I must specify that the first column is the date.
There is additiona problem with wfopen. I do not want to read the data into the new workfile. I want to read one file, do the calculations, save the results, read new file, do the same calculations on new data, save the results. Since the columns have the same names, when reading the new data, I want to overwrite the existing ones.
I would guess that I might use wfopen for the first file, but afterwards I should use import. However, I would like to specify import options in such a way that import will automatically recognize date culomn.
Similarly, I want the script to rewrite the old data (e.g. PRC) by the new data automatically, without asking me about this.
thank you
Peter
btw: I started to use Eviews only recently, because it seems to be great software. E.g. unlike other statistical packages, eviews can estimate GARCH model with exogeneous variables in the variance equation. However, regarding programming in eviews, I have mixed feelings. Programming itself does not seem to be difficult, but I find the help and manuals unsatisfactory. I believe that many people would appriciate some more comprehensive "eviews progamming tutorials", with more sample codes etc.
Actually, you did a great job here: http://forums.eviews.com/viewtopic.php?f=5&t=1638
This would be a great beginning of an eviews programming tutorial. Tutorial written this way, but covering much more topics would be very useful. I know it would be a huge project, but I think it would be worth it.
When I use "wfopen 1.csv", then the window "text read - step 1 of 4" pops up. Here I must specify that the first column is the date.
There is additiona problem with wfopen. I do not want to read the data into the new workfile. I want to read one file, do the calculations, save the results, read new file, do the same calculations on new data, save the results. Since the columns have the same names, when reading the new data, I want to overwrite the existing ones.
I would guess that I might use wfopen for the first file, but afterwards I should use import. However, I would like to specify import options in such a way that import will automatically recognize date culomn.
Similarly, I want the script to rewrite the old data (e.g. PRC) by the new data automatically, without asking me about this.
thank you
Peter
btw: I started to use Eviews only recently, because it seems to be great software. E.g. unlike other statistical packages, eviews can estimate GARCH model with exogeneous variables in the variance equation. However, regarding programming in eviews, I have mixed feelings. Programming itself does not seem to be difficult, but I find the help and manuals unsatisfactory. I believe that many people would appriciate some more comprehensive "eviews progamming tutorials", with more sample codes etc.
Actually, you did a great job here: http://forums.eviews.com/viewtopic.php?f=5&t=1638
This would be a great beginning of an eviews programming tutorial. Tutorial written this way, but covering much more topics would be very useful. I know it would be a huge project, but I think it would be worth it.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13602
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Import several xls or csv files
Could you explain in more detail what goes wrong with using wfopen and import?
seems to work just fine for me. It appears to bring in the data correctly.
Similarly, using
appears to import the 2nd file into the workfile correctly.
Code: Select all
wfopen 1.csv
Similarly, using
Code: Select all
import 2.csv
Re: Import several xls or csv files
Hi,
I made a snapshot (see attachment). After typing "wfopen 1.csv", the pop up window (1.png) shows up. I must specify that first culomn is a date culomn and click couple of times on "next" and "finish" buttoms. I would like if this could be done automatically. This might sound stupid, but I expect to do similar calculations later over and over. This is particulat important with "import" command. (see my next post).
I made a snapshot (see attachment). After typing "wfopen 1.csv", the pop up window (1.png) shows up. I must specify that first culomn is a date culomn and click couple of times on "next" and "finish" buttoms. I would like if this could be done automatically. This might sound stupid, but I expect to do similar calculations later over and over. This is particulat important with "import" command. (see my next post).
- Attachments
-
- 1.png (44.67 KiB) Viewed 16882 times
Re: Import several xls or csv files
Hi,
my problem with import command is very similar to wfopen command (see attached files). In the first step, I must specify that the first colomn is a date colomn (snapshot 1.png). Next I must specify which type of import it should be (spanshot 3.png): dated read, matched read, sequential read, append to end or create new page. In my case, all dated read, matched read and sequential read should work. I tried dated read and it works.
In the end, since the old variables from the file 1.csv have the same names as the new ones, I have to do something (snapshot 4.png). I chose "overwrite object - all" and it works.
I would like all of this to be done automatically, without my help. In other words, instead of typing:
wfopen 1.csv
import 2.csv
and specifying import options interactively by clicking, I would like to type something like this:
wfopen([yyyymmdd, do_not_import_this culomn, number, number]) 1.csv
import([yyyymmdd, do_not_import_this culomn, number, number], dated_import, in case of variables with same names, overwrite the old ones ) 2.csv
to make the import automatic.
I hope it is possible.
thank you
my problem with import command is very similar to wfopen command (see attached files). In the first step, I must specify that the first colomn is a date colomn (snapshot 1.png). Next I must specify which type of import it should be (spanshot 3.png): dated read, matched read, sequential read, append to end or create new page. In my case, all dated read, matched read and sequential read should work. I tried dated read and it works.
In the end, since the old variables from the file 1.csv have the same names as the new ones, I have to do something (snapshot 4.png). I chose "overwrite object - all" and it works.
I would like all of this to be done automatically, without my help. In other words, instead of typing:
wfopen 1.csv
import 2.csv
and specifying import options interactively by clicking, I would like to type something like this:
wfopen([yyyymmdd, do_not_import_this culomn, number, number]) 1.csv
import([yyyymmdd, do_not_import_this culomn, number, number], dated_import, in case of variables with same names, overwrite the old ones ) 2.csv
to make the import automatic.
I hope it is possible.
thank you
- Attachments
-
- 4.png (19.33 KiB) Viewed 16883 times
-
- 3.png (44.51 KiB) Viewed 16883 times
-
- 2.png (45.51 KiB) Viewed 16883 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13602
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Import several xls or csv files
If I understand you correctly, you're suggesting that you need to do more than simply hit Finish on both the open and the import. i.e. you need to change the options on them. Both of those commands have a full set of options that mirror those in the dialogs. You can find the options in the command reference.
Note that if you run those commands in a program (rather than from the command line) those dialogs do not show up at all.
Note that if you run those commands in a program (rather than from the command line) those dialogs do not show up at all.
Re: Import several xls or csv files
Thanks a lot, I did not know that "Note that if you run those commands in a program (rather than from the command line) those dialogs do not show up at all."
:-) I am happy.
:-) I am happy.
Who is online
Users browsing this forum: No registered users and 2 guests
