Date: Tue, 10 May 2005 02:36:19 -0000
Reply-To: sa polo <email@example.com>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: sa polo <solouga2@REDIFFMAIL.COM>
Subject: Re: Processing multiple CSV files from a directory
Content-Type: text/plain; charset=iso-8859-1
Yes i agree this does not seem to be a SAS like task, but unfortunately i do not know how to do it in pearl or any other
language. I thought it might be interesting to program it in SAS,
i actually do not need the entire input file but only
those records which have the first csv field that begins
Is it possible to read the files , process them and write them
back as CSV file rather than first writing it to a dataset and then to
a CSV file .
All assistance is much appreciated as usual.
On Tue, 10 May 2005 David L.Cassell wrote :
>sa polo <solouga2@REDIFFMAIL.COM> wrote:
> > Hi All,
> > I am attempting to write a program to
> > read CSv files from several sub-directories and process them
> > by adding a date field and part of the file name to the new
> > file which is again in CSV format.
> > Directory: c:\
> > Sub-Dirs : 20010101, 20010102 .................
> > CSV Files in each directory abc_a.csv, abc_ab.csv abc_se.csv abc_po.
> > csv abc_**** .........
> > Extract the data from each file merge the date(obtained from the sub-
> > directory) in date9. format and whatever appears after the
> > _(underscore ) in the
> > file name .
> > example
> > File abc_a in directory 20010101:
> > 1,se,oo,poll
> > output
> > 1,se,oo,poll,01JAN2001,a
> > The program should read all the sub-directories in the directory
> > in this case c:\ and process all files and write them to a separate
> > location on say another drive or directory in the same csv format .
>This seems like a non-SAS kind of task.
>And it seems like a waste of your time. You're taking flat files,
>reading in information which will be duplicated on every single
>record of the file so it will be even larger, then leaving the
>files as flat files. Is there a reason you need to have the files
>like this? If you were reading all the files into one central
>database, I could see tacking this sort of information onto the
>file data.. although I would try to see if there were a way to
>have the extra data in a view or auxiliary data set instead.
>Perhaps you should write back to SAS-L and explain why you want to
>do this task. Not what you already said, but the bigger picture.
>And also tell why you don't want the data as a SAS data set. SAS
>reads its own files a lot faster than flat files.
>David Cassell, CSC
>Senior computing specialist
>"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> wrote on 05/09/2005