05-12-2008
Splitting a file based on the records in another file
All,
We receive a file with a large no of records (records can vary) and we have to split it into two files based on another file. e.g.
File1:
UHDR 2008112
"25187","00000022","00",21-APR-1991,"" ,"D",-000000519,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,21-APR-1991
"8Y3H4","0000004H","00",16-APR-1992,"" ,"H",-001621119,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,21-APR-1991
"95Y8U","02100971","00",03-MAR-1991,"" ,"H",-000004499,+0000000000,"" , ,+000000000,+000000000,000000000,"2","US",21-APR-1991
"24567","02100973","00",26-SEP-1991,"" ,"H",-000000362,+0000000000,"" , ,+000000000,+000000000,000000000,"2","US",21-APR-1991
--
--
--
UTRL 00144700
File2:
2518720080512
2456720080512
1256720080512
8WE7820080512
8Y3H020080512
8Y3H220080512
8Y3H420080512
8Y3H620080512
-
--
--
--
If the first 5 characters of file 2 matched with the chars 2-6 in file1, it should separate those records and put them into another file and rest of the records should be copied into a second file.
I tried cut command but as the file1 is quite large, it was taking a lot of time to put the values into a variable and then compare it.
Is there a way which can do the above task quite fast.
Please help as it is needed urgently.
Thanks in anticipation.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
All,
We receive a file with a large no of records (records can vary) and we have to split it into two files based on another file. e.g.
File1:
UHDR 2008112
"25187","00000022","00",21-APR-1991,"" ,"D",-000000519,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,21-APR-1991... (7 Replies)
Discussion started by: er_ashu
7 Replies
2. Shell Programming and Scripting
Hi there,
I've an input file as follows:
*START
1001 a1
1002 a2
1003 a3
1004 a4
*END
*START
1001 b1
1002 b2
1004 b4
*END
*START
1001 c1
1004 c4
*END (6 Replies)
Discussion started by: kbirde
6 Replies
3. Shell Programming and Scripting
I have file as shown below. Would like to split the file based on the context of data.
Like, split the content between "---- XXX Info ----" and "
---- YYY Info ----" to a file.
When I try using below command, 2nd file contains all the info starting after first "---- YYYY Info ----" instance.... (8 Replies)
Discussion started by: webkid
8 Replies
4. Shell Programming and Scripting
Hello gurus,
I am new to "awk" and trying to break a large file having 4 million records into several output files each having half million but at the same time I want to keep the similar key records in the same output file, not to exist accross the files.
e.g. my data is like:
Row_Num,... (6 Replies)
Discussion started by: kam66
6 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I am looking for an awk script which should help me to meet the following requirement:
File1 has records in following format
INF: FAILEd RECORD AB1234
INF: FAILEd RECORD PQ1145
INF: FAILEd RECORD AB3215
INF: FAILEd RECORD AB6114
............................ (2 Replies)
Discussion started by: mintu41
2 Replies
6. Shell Programming and Scripting
A text file has 2 fields (Data, Filename) delimited by # as below,
Data,Filename
Row1 -> abc#Test1.xml
Row2 -> xyz#Test2.xml
Row3 -> ghi#Test3.xml
The content in first field has to be written into a file where filename should be considered from second field.
So from... (4 Replies)
Discussion started by: jayakkannan
4 Replies
7. UNIX for Dummies Questions & Answers
Dear All,
I have two files but want to extract data from one based on another... can you please help me
file 1
David
Tom
Ellen
and file 2
David|0010|testnamez|resultsz
David|0004|testnamex|resultsx
Tom|0010|testnamez|resultsz
Tom|0004|testnamex|resultsx
Ellen|0010|testnamez|resultsz... (12 Replies)
Discussion started by: A-V
12 Replies
8. Shell Programming and Scripting
Hi
I have two files one.txt and two.txt
one.txt
123
324
456
235
456
two txt
abc one 000 123 abc
abc one 000 456 abc
abc one 000 122 abc
abc one 000 111 abc
My question here is, the records which are present in one.txt has to deleted in second file two.txt
my output result... (2 Replies)
Discussion started by: Ganesh L
2 Replies
9. Shell Programming and Scripting
Hello I have a file of following format
HDR 1234 abc qwerty
abc def ghi jkl
HDR 4567 xyz qwerty
abc def ghi jkl
HDR 890 mno qwerty
abc def ghi jkl
HDR 1234 abc qwerty
abc def ghi jkl
HDR 1234 abc qwerty
abc def ghi jkl
-Need to split this into multiple files based on tag... (8 Replies)
Discussion started by: wincrazy
8 Replies
10. UNIX for Beginners Questions & Answers
Hi ,
I am having a scenario where I need to split the file based on two field values. The file is a fixed length file.
ex:
AA0998703000000000000190510095350019500010005101980301
K 0998703000000000000190510095351019500020005101480 ... (4 Replies)
Discussion started by: saj
4 Replies
LEARN ABOUT DEBIAN
apr::request::parser
Parser(3pm) User Contributed Perl Documentation Parser(3pm)
NAME
APR::Request::Parser - wrapper for libapreq2's parser API.
SYNOPSIS
use APR::Request::Parser;
DESCRIPTION
This manpage documents version 2.13 of the APR::Request::Parser package.
METHODS
APR::Request::Parser
generic
APR::Request::Parser->generic($pool, $ba, $ct)
APR::Request::Parser->generic($pool, $ba, $ct, $blim)
APR::Request::Parser->generic($pool, $ba, $ct, $blim, $tdir)
APR::Request::Parser->generic($pool, $ba, $ct, $blim, $tdir, $hook)
Noop-parser that collects everything into a single, internal parameter. Here $pool is an APR::Pool object, $ba is an APR::BucketAlloc
object, and $ct is the Content-Type header of the request. Optionally $blim is the brigade in-memory limit, $tdir is the path to the
temporary directory, and $hook is an APR::Request::Hook object.
headers
APR::Request::Parser->headers($pool, $ba, $ct)
APR::Request::Parser->headers($pool, $ba, $ct, $blim)
APR::Request::Parser->headers($pool, $ba, $ct, $blim, $tdir)
APR::Request::Parser->headers($pool, $ba, $ct, $blim, $tdir, $hook)
RFC 822 header parser. Here $pool is an APR::Pool object, $ba is an APR::BucketAlloc object, and $ct is the Content-Type header of the
request. Optionally $blim is the brigade in-memory limit, $tdir is the path to the temporary directory, and $hook is an APR::Request::Hook
object.
urlencoded
APR::Request::Parser->urlencoded($pool, $ba, $ct)
APR::Request::Parser->urlencoded($pool, $ba, $ct, $blim)
APR::Request::Parser->urlencoded($pool, $ba, $ct, $blim, $tdir)
APR::Request::Parser->urlencoded($pool, $ba, $ct, $blim, $tdir, $hook)
x-www-form-urlencoded parser. Here $pool is an APR::Pool object, $ba is an APR::BucketAlloc object, and $ct is the Content-Type header of
the request. Optionally $blim is the brigade in-memory limit, $tdir is the path to the temporary directory, and $hook is an
APR::Request::Hook object.
multipart
APR::Request::Parser->multipart($pool, $ba, $ct)
APR::Request::Parser->multipart($pool, $ba, $ct, $blim)
APR::Request::Parser->multipart($pool, $ba, $ct, $blim, $tdir)
APR::Request::Parser->multipart($pool, $ba, $ct, $blim, $tdir, $hook)
Multipart parser. Here $pool is an APR::Pool object, $ba is an APR::BucketAlloc object, and $ct is the Content-Type header of the request.
Optionally $blim is the brigade in-memory limit, $tdir is the path to the temporary directory, and $hook is an APR::Request::Hook object.
default
APR::Request::Parser->default($pool, $ba, $ct)
APR::Request::Parser->default($pool, $ba, $ct, $blim)
APR::Request::Parser->default($pool, $ba, $ct, $blim, $tdir)
APR::Request::Parser->default($pool, $ba, $ct, $blim, $tdir, $hook)
Default parser. Here $pool is an APR::Pool object, $ba is an APR::BucketAlloc object, and $ct is the Content-Type header of the request.
Optionally $blim is the brigade in-memory limit, $tdir is the path to the temporary directory, and $hook is an APR::Request::Hook object.
SEE ALSO
APR::Request, APR::Request::Hook
COPYRIGHT
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
perl v5.10.1 2011-02-28 Parser(3pm)