Hi Guys,
I have yet another weird question. If I tell eviews the location of a particular folder, is there a way to make it spell out all the file names within a folder and record the names into a table or something? Let me give you an example:
If I have a folder called "C:/eviews7/ABC/" and there are n number of csv files in it, is there a way to write a piece of code such that eviews would create a (nx1) table where each cell contains a unique file name (stripped off the .csv part, which I know how to do as long as I could read it one by one as a string)?
If you have any ideas/hints/clues, please let me know. Thanks.
Tchaithonov
Automatically read file names in a folder
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
tchaithonov
- Posts: 168
- Joined: Mon Apr 13, 2009 7:39 am
- Location: New York City
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Automatically read file names in a folder
The EViews 7 function @wdir should be enough to get you going.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13602
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Automatically read file names in a folder
Before remembering the @wdir command, I came up with a manual way of doing it, which is clearly beaten by @wdir, but is instructional nevertheless:
which will create an svector called filelist containing all the files in the directory c:\temp
Code: Select all
create u 10
cd c:\temp
shell dir /b > dir.txt
text dirlist
dirlist.append(file) dir.txt
dirlist.svector filelist
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13602
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Automatically read file names in a folder
You could also use the example in the manual :D :
which will make a table object containing the directory contents.
Code: Select all
shell(out=flist) dir /b
-
tchaithonov
- Posts: 168
- Joined: Mon Apr 13, 2009 7:39 am
- Location: New York City
Re: Automatically read file names in a folder
Excellent suggestions guys! Thanks very much indeed. I will try this out once I finish dealing with another issue...
Who is online
Users browsing this forum: No registered users and 2 guests
