There is (was) a commercial package that had awk, sed, grep, et al. and when I used it (pre XP) it did a fine job.  I can't remember the name off hand, but I think it originated in Israel.  Since then, I have occasionally come across a package or two, but I never took a closer look since I get this automatically on Linux...
 
Given the "rules" regarding standardization where I work, it wouldn't be an option for me...  If it smells like a PC and looks like a PC, then the IT division owns it to the point where you have to get permission to change your desktop configuration!  I can't even auto-update as I do not have administrator permissions...
 
Steve

 
On 7/25/07, Eric Martin <freak4uxxx@gmail.com> wrote:
does awk compile on windows?


On 7/25/07, Michael Long <mlong@datalong.com > wrote:
Chuck Anderson wrote:
> On Wed, Jul 25, 2007 at 09:29:43AM -0400, Stephen Daukas wrote:
>> There are literally hundreds of files of data in CSV format, and I intend to
>> process each by itself, preserving the original, and creating a new
>> "adjusted" file for the next step.  (The next step would be to concatenate
>> all files together for numeric processing.)  Original files must be
>> preserved (chain of custody requirements), so I am opening the file,
>> selecting records using SQL, and am now ready to do the rearranging/writing
>> to a new file...
>
> So you are selecting records out of a CSV file using SQL?  How about
> this:
>
> select columnB,columnG,columnA,columnC,columnF from foo;
>
> That will take the columns and return them in the given order.
> _______________________________________________

That will work if the column order of the csv file is known. If the
files come in with the columns in different orders and you have to
examine the headers to determine the order or the data then it becomes
more complex.

If he really wants to do this in sql then you could bulk load the data
into a worktable with all columns defined and char or varchar. When the
data is loaded make sure you have a unique key for each row by defining
one of the columns as an identity column.

create table foo (
        col1 identity(1,1), col2 varchar(25), col3 varchar(25)
)

Once the data is imported you could right a sql script that will move
the data based on the value found in the first record.

if (select col2 from foo where col1 = 1) = 'myHeader'
begin
        insert into myTable(myHeader)
        select col2 from foo
end

if (select col3 from foo where col1 = 1) = 'myHeader'
begin
        insert into myTable(myHeader)
        select col3 from foo where col1 > 1
end

Repeat this as necessary. Also be careful to keep the rows ordered as
you move the data around. You will also need to reset the identity value
between loads or come up with a method to deal with an incrementing number.


_______________________________________________
Wlug mailing list
Wlug@mail.wlug.org
http://mail.wlug.org/mailman/listinfo/wlug


_______________________________________________
Wlug mailing list
Wlug@mail.wlug.org
http://mail.wlug.org/mailman/listinfo/wlug




--
Stephen C. Daukas
Engineer, Geoscientist,
Environmental Analyst
________________________________________________
- Please, before printing, think about the environment -