Sponsored Content
Top Forums Shell Programming and Scripting Splitting a file and creating new files using Perl script Post 302823305 by Deepak9870 on Wednesday 19th of June 2013 06:02:30 AM
Old 06-19-2013
Splitting a file and creating new files using Perl script

Hi All,

I am new to Scripting language.
I want to split a file and create several subfiles using Perl script.

Example :
File format :
Code:
Sourcename		ID			Date	               Nbr	
SU				IMYFDJ		9/17/2012	   5552159976555	
SU				BWZMIG		9/14/2012	   1952257857887	
AR				PEHQDF		11/26/2012	   0442045903874	
AR				ELIOAA		12/31/2012	   0442121341024

I want to split this files by Sourcename.
As this has two source name, so it will be splitting into two.

File 1 (after splitting) :

Code:
Sourcename		ID				Date	       Nbr	
SU				IMYFDJ			9/17/2012	5552159976555	
SU				BWZMIG			9/14/2012	1952257857887

File 2 (after splitting) :

Code:
Sourcename		ID				Date	       Nbr	
AR				PEHQDF			11/26/2012	0442045903874	
AR				ELIOAA			12/31/2012	0442121341024

Thanks a lot in advance,
Deepak

Last edited by Franklin52; 06-19-2013 at 07:06 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating loop for a script -Perl

Hi Guyz I designed a script that can compare 2 columns(values) of single file and gives the closest numbers to the first column by comparing the numbers in first column with second and it works in a single file. Now I'm trying to design a new script with 2 objectives for 2 files (not a single... (4 Replies)
Discussion started by: repinementer
4 Replies

2. Shell Programming and Scripting

Splitting files from one file

Hi, I have an input file like: 111 abcdefgh asdfghjk dfghjkl 222 aaaaaaa bbbbbb 333 djfhfgjktitjhgfkg 444 djdhfjkhfjkghjkfg hsbfjksdbhjkgherjklg fjkhfjklsahjgh fkrjkgnj I want to read this input file and make separate output files with the header as numric value like "111"... (9 Replies)
Discussion started by: saltysumi
9 Replies

3. Shell Programming and Scripting

Splitting the files via shell script

Hi all, We have 102 flat files created by Informatica from 102 tables. These 102 files contain pharmcy details. There are a total of 450 pharmcyids.The naming convention for the flat file is ODS_<TABLE NAME>_yyyymmdd_timestamp.dat. Each flat file may contain data for 450 pharmacies which is... (2 Replies)
Discussion started by: Maya_Pillai
2 Replies

4. Shell Programming and Scripting

Splitting file into 2 files ?

Hi extending to one of my previous posted query .... I am using nawk -v invar1="$aa" '{print > ("ABS\_"((/\|/)?"A\_":"B\_")invar1"\_NETWORKID.txt")}' spfile.txt to get 2 different files based on split condition i.e. "|" Similar to invar1 variable in nawk I also need one more variable... (18 Replies)
Discussion started by: shekharjchandra
18 Replies

5. Shell Programming and Scripting

Data Splitting into two files from one file

I have a file as: I/P File: Ground Car 2009 Lib 2008 Lib 2003 Ground Car 2009 Ground Car 2003 Car 2005 Car 2003 Car 2005 Sita 2900 2006 Car 2007 I have to split the file into two: - one for names and second for years. O/p1 (Names): Ground Car (3 Replies)
Discussion started by: karumudi7
3 Replies

6. UNIX for Advanced & Expert Users

Splitting a file into small files

Hi Folks, Please help me in solving the problem. I want to write script in order to split a file into small pieces and send it automatically through mail. Ex. The file name is CALM*.txt . It is around 50 MB. I want to split the file into 20 MB 2-3 smaller files and send (like uuencode) it... (6 Replies)
Discussion started by: piyushbhashkar
6 Replies

7. Shell Programming and Scripting

Splitting a file into several smaller files using perl

Hi, I'm trying to split a large file into several smaller files the script will have two input arguments argument1=filename and argument2=no of files to be split. In my large input file I have a header followed by 100009 records The first line is a header; I want this header in all my... (9 Replies)
Discussion started by: ramky79
9 Replies

8. Shell Programming and Scripting

Splitting xml file into several xml files using perl

Hi Everyone, I'm new here and I was checking this old post: /shell-programming-and-scripting/180669-splitting-file-into-several-smaller-files-using-perl.html (cannot paste link because of lack of points) I need to do something like this but understand very little of perl. I also check... (4 Replies)
Discussion started by: mcosta
4 Replies

9. Shell Programming and Scripting

Script for splitting file of records into multiple files

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

Creating script to read many files and load into database via single control file

Hi, I have many files but with only 2 names , I want to load the data of that file into database through sqlldr with single control file. how can i do that ????? Example: switch_file switch_file billing_file billing_file now these files should be loaded into same database but different... (1 Reply)
Discussion started by: niti_sharma
1 Replies
IO::Async::Signal(3pm)					User Contributed Perl Documentation				    IO::Async::Signal(3pm)

NAME
"IO::Async::Signal" - event callback on receipt of a POSIX signal SYNOPSIS
use IO::Async::Signal; use IO::Async::Loop; my $loop = IO::Async::Loop->new; my $signal = IO::Async::Signal->new( name => "HUP", on_receipt => sub { print "I caught SIGHUP "; }, ); $loop->add( $signal ); $loop->run; DESCRIPTION
This subclass of IO::Async::Notifier invokes its callback when a particular POSIX signal is received. Multiple objects can be added to a "Loop" that all watch for the same signal. The callback functions will all be invoked, in no particular order. EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters: on_receipt Invoked when the signal is received. PARAMETERS
The following named parameters may be passed to "new" or "configure": name => STRING The name of the signal to watch. This should be a bare name like "TERM". Can only be given at construction time. on_receipt => CODE CODE reference for the "on_receipt" event. Once constructed, the "Signal" will need to be added to the "Loop" before it will work. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Signal(3pm)
All times are GMT -4. The time now is 05:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy