04-10-2012
Split a file into multiple files based on first two digits of file.
Hi ,
I do have a fixedwidth flatfile that has data for 10 different datasets each identified by the first two digits in the flatfile.
01 in the first two digit position refers to Set A
02 in the first two digit position refers to Set B and so on
I want to genrate 10 different files from my fixedwidth file , each file having it's own record set.
File A.dat having only 01 records.
File B.dat having only 02 records and so on.
Please Let me know how we can achieve this.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have a file like below:
1016D"ddd","343","1299"
1016D"ddd","3564","1299"
1016D"ddd","3297","1393"
1016D"ddd","32989","1527"
1016D"ddd","346498","1652"
2312D"ddd","3269","1652"
2312D"ddd","328","1652"
2312D"ddd","2224","2100"
3444D"ddd","252","2100"
3444D"ddd","2619","2100"... (4 Replies)
Discussion started by: deepakgang
4 Replies
2. Shell Programming and Scripting
Dear All,
I would like to split a file of the following format into multiple files based on the number in the 6th column (numbers 1, 2, 3...):
ATOM 1 N GLY A 1 -3.198 27.537 -5.958 1.00 0.00 N
ATOM 2 CA GLY A 1 -2.199 28.399 -6.617 1.00 0.00 ... (3 Replies)
Discussion started by: tomasl
3 Replies
3. Shell Programming and Scripting
I have a file with lines something like.
......
123_start
......
.......
123_end
....
.....
456_start
......
.....
456_end
....
.....
789_start
....
....
789_end (6 Replies)
Discussion started by: abinash
6 Replies
4. Shell Programming and Scripting
Hello, I am using awk to split a file into multiple files using command:
nawk '{
if ( $1 == "<process" )
{
n=split($2, arr, "\"");
file=arr
}
print > file }' processes.xml
<process name="Process1.process">
... (3 Replies)
Discussion started by: chiru_h
3 Replies
5. Shell Programming and Scripting
Hi,
I've one requirement. I have to split one comma delimited file into multiple files based on one of the column values.
How can I achieve this Unix
Here is the sample data. In this case I have split the files based on date column(c4)
Input file
c1,c2,c3,c4,c5... (1 Reply)
Discussion started by: manasvi24
1 Replies
6. Shell Programming and Scripting
Good day all
I need some helps,
say that I have data like below, each field separated by a tab
DATE NAME ADDRESS
15/7/2012 LX a.b.c
15/7/2012 LX1 a.b.c
16/7/2012 AB a.b.c
16/7/2012 AB2 a.b.c
15/7/2012 LX2 a.b.c... (2 Replies)
Discussion started by: alexyyw
2 Replies
7. Shell Programming and Scripting
So I have a space delimited file that I'd like to split into multiple files based on multiple column values.
This is what my data looks like
1bc9A02 1 10 1000 FTDLNLVQALRQFLWSFRLPGEAQKIDRMMEAFAQRYCQCNNGVFQSTDTCYVLSFAIIMLNTSLHNPNVKDKPTVERFIAMNRGINDGGDLPEELLRNLYESIKNEPFKIPELEHHHHHH
1ku1A02 1 10... (9 Replies)
Discussion started by: viored
9 Replies
8. Shell Programming and Scripting
I have a requirement to split a huge file to smaller text files based on first four characters which look like
ABCD
1234
DFGH
RREX
:
:
:
:
:
0000
Each of these records are OF EQUAL bytes with a different internal layout based on the above first digit identifier..
Any help to start... (5 Replies)
Discussion started by: etldev
5 Replies
9. Shell Programming and Scripting
Hi All,
I have the sales_data.csv file in the directory as below.
SDDCCR; SOM ; MD6546474777 ;05-JAN-16
ABC ; KIRAN ; CB789 ;04-JAN-16
ABC ; RAMANA; KS566767477747 ;06-JAN-16
ABC ; KAMESH; A33535335 ;04-JAN-16
SDDCCR; DINESH; GD6674474747 ;08-JAN-16... (4 Replies)
Discussion started by: ROCK_PLSQL
4 Replies
10. UNIX for Beginners Questions & Answers
I am using below code to split files based on blank lines but it does not work.
awk 'BEGIN{i=0}{RS="";}{x="F"++i;}{print > x;}'
Your help would be highly appreciated
find attachment of sample.txt file (2 Replies)
Discussion started by: imranrasheedamu
2 Replies
LEARN ABOUT DEBIAN
file::queue
File::Queue(3pm) User Contributed Perl Documentation File::Queue(3pm)
NAME
File::Queue - Persistent FIFO queue implemented in pure perl!
SYNOPSIS
use strict; # always!
use File::Queue;
my $q = new File::Queue (File => '/var/spool/yourprog/queue');
$q->enq('some flat text1');
$q->enq('some flat text2');
$q->enq('some flat text3');
# Get up to first 10 elements
my $contents = $q->peek(10);
my $elem1 = $q->deq();
my $elem2 = $q->deq();
# empty the queue
$q->reset();
DESCRIPTION
This module allows for the creation of persistent FIFO queue objects.
File::Queue only handles scalars as queue elements. If you want to work with references, serialize them first!
The module was written with speed in mind, and it is very fast, but it should be used with care. Please refer to the CAVEATS section.
Interface
File::Queue implements a OO interface. The object methods and parameters are described below.
Methods
File::Queue supports all of the queue-related functions a developer should expect.
o new()
Instantiates your File::Queue object. Parameters are described in the next sub-section.
o enq()
Enqueues a string element to the queue.
o deq()
Dequeues a string element from the queue, and returns the element. If the queue is empty, nothing is returned.
o peek(n)
Returns an arrayref containing the next n elements in the queue. If the queue size is less than n, all elements are returned. If the
queue is empty, an empty arrayref is returned.
o reset()
Emptys the queue.
o close()
Closes the filehandles belonging to the queue object ('.dat' and '.idx').
o delete()
Deletes the files belonging to the queue object ('.dat' and '.idx').
Parameters
There are a number of parameters that can be passed when constructing your File::Queue objects. Parameters are case-insensitive.
o File (required)
File::Queue creates two files using this parameter as the base. In the case of the example in the SYNOPSIS, the two files are
'/var/spool/yourprog/queue.dat' and '/var/spool/yourprog.idx'.
The '.dat' file holds all of the data, the '.idx' file holds the byte index (pointer) of the starting point of the first element in the
queue.
o Mode (optional)
The file bit mode to be shared by both the '.dat' and '.idx' files. Defaults to '0600'.
o Seperator (optional)
The character or byte sequence that is used to seperate queue elements in the '.dat' file. It should be something you can guarantee
will NEVER appear in your queue data. Defaults to the newline character.
o BlockSize (optional)
This is the size of the byte chunks that are pulled at each iteration when checking for the end of a queued element. Defaults to 64,
which will be fine for most cases, but can be tweaked or tuned for your specific case to squeeze out a few extra nanoseconds.
CAVEATS
This module should never be used in situations where the queue is not expected to become empty.
The '.dat' file is not truncated (emptied) until the queue is empty.
Even the data you've already dequeued remains in the '.dat' file until the queue is empty.
If you keep enqueueing elements and never FULLY dequeue everything, eventually your disk will fill up!
SEE ALSO
Tie::File
AUTHOR
Jason Lavold <jlavold [ at ] gmail.com>
perl v5.10.0 2008-12-22 File::Queue(3pm)