Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Need A Split File Option

Re: Need A Split File Option

From: GovindanK <gkatteri_at_fastmail.fm>
Date: Thu, 13 Nov 2003 11:49:31 -0800
Message-ID: <F001.005D6941.20031113114931@fatcity.com>

$ cat myfile.dat
WI auto
WI Auto
NY auto
ny Auto
Junk auto
$ cp /dev/null my_file.tmp
$ for pattern in wi ny
> do
> cp /dev/null "$pattern"_auto
> grep -i "$pattern auto" myfile.dat >> "$pattern"_auto
> #Repeat above command and 'accumulate' to tmp file
> grep -i "$pattern auto" myfile.dat >> myfile.tmp
> done

$ ls -l *auto*
-rw-r--r--   1 govindankappdev1       16 Nov 13 11:43 ny_auto
-rw-r--r--   1 govindankappdev1       16 Nov 13 11:43 wi_auto
$ more myfile.dat
WI auto
WI Auto
NY auto
ny Auto
Junk auto
$ more wi_auto
WI auto
WI Auto
$ more ny_auto
NY auto
ny Auto
$ ls -lrt *myfile*
-rw-r--r--   1 govindankappdev1       42 Nov 13 11:40 myfile.dat
-rw-r--r--   1 govindankappdev1       32 Nov 13 11:43 myfile.tmp
$ more myfile.tmp
WI auto
WI Auto
NY auto
ny Auto
$ diff myfile.dat myfile.tmp
5d4
< Junk auto
$

HTH
GovindanK

On Thu, 13 Nov 2003 11:24:25 -0800, "Tracy Rahmlow" <tracy.rahmlow_at_aexp.com> said:
> A developer in our shop would like to read an input file and based on
> some
> field values for each record in the file split them into multiple files.
> The
> output files will be used by a 3rd party package for processing. (the
> package
> does not need the oracle database) For example:
>
> Input File:
> record a: WI auto ...
> record b: WI auto ...
> record c: NY auto ...
> record d: YY home ...
>
>
> Output file WI_AUTO:
> record a: WI auto ...
> record b: WI auto ...
>
> Output file NY_AUTO:
> record c: NY auto ...
>
> Error file:
> record d: YY home ... (no entry in the criteria lookup table to pick up
> this
> record therefore send it to an error file)
>
> Their solution is to load an oracle table with the input file. An
> additional
> table would contain the criteria and the name of the output file to write
> to.
> They would write a procedure to read the criteria and input table and
> utilize
> the utl_file package to create the output files. There may be 50+ output
> files
> initially and likely will grow over time. My gut tells me that this does
> not
> belong in the database, rather we should be able to split the file using
> C or a
> utility such as syncsort (which we do not have). We are currently at
> 8.1.7.4
> on AIX 4.3.3. Is there a more elegant solution and what would it be???
> Are
> there any open source unix utilities that may help? Thanks
>

-- 
http://www.fastmail.fm - Or how I learned to stop worrying and
                          love email again
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: GovindanK
  INET: gkatteri_at_fastmail.fm

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Thu Nov 13 2003 - 13:49:31 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US