Sponsored Content
Top Forums Programming Problem with Mail merge in perl Post 302579537 by sunnyboy on Tuesday 6th of December 2011 02:10:27 AM
Old 12-06-2011
Problem with Mail merge in perl

This could be a simple problem for the perl experts

I am trying mail merge in perl

The header file is head1 which is as under

,,ACTION,TRANS_ID,,TBL,ForwardDeals_Id,DealStatus,InputMode,CaptureDate,TradeDate,Users_Id,Users_Id_ Last,Folders_Id,Purposes_Id,TypeOfEvent,BlockNumber,TypeOfInstr_Id,Comments,Pairs_Id,Amount1,Amount2 ,

The file containing the values is csv which is as under

,,"INS",973795,,ForwardDeals,883797,V,I,"04/05/2009,04/05/2009,63768,0,63761,61987,K,887591,58935,"649978-booked,52006,-475000.0,23607500.0
,,"INS",973796,,ForwardDeals,883798,V,I,"04/05/2009,04/05/2009,63768,0,63761,61987,K,887592,58935,"649978-booked,52006,-575000.0,33607500.0
,,"INS",973797,,ForwardDeals,883799,V,I,"04/05/2009,04/05/2009,63768,0,63761,61987,K,887593,58935,"649978-booked,52006,-478000.0,23608500.0

The perl script is to merge the head and csv is

#!/usr/bin/perl
while ($f = (head1)) {
open (FH, $f) or die "Can't open $f : $!";
while (<FH>) {
chomp;
push @contents, $_;
@contents = split(/,/);
}
while (<>) {
chop() ;
push @values, $_;
@values = split(/,/);
$size = @values;
}
for ($i = 0 ;$i < $size ; $i++) {
printf "$contents[$i] $values[$i] \n" ;
}
}

I am able to get the merge for 1st row of the csv file and the head1 as under by executing

perl mail_merge.pl csv


ACTION "INS"
TRANS_ID 973795

TBL ForwardDeals
ForwardDeals_Id 883797
DealStatus V
InputMode I
CaptureDate "04/05/2009
TradeDate 04/05/2009
Users_Id 63768
Users_Id_Last 0
Folders_Id 63761
Purposes_Id 61987
TypeOfEvent K
BlockNumber 887591
TypeOfInstr_Id 58935
Comments "649978-booked
Pairs_Id 52006
Amount1 -475000.0
Amount2 23607500.0

I am not able to merge the head with the subsequent rows of csv .The desired output would be

ACTION "INS"
TRANS_ID 973795

TBL ForwardDeals
ForwardDeals_Id 883797
DealStatus V
InputMode I
CaptureDate "04/05/2009
TradeDate 04/05/2009
Users_Id 63768
Users_Id_Last 0
Folders_Id 63761
Purposes_Id 61987
TypeOfEvent K
BlockNumber 887591
TypeOfInstr_Id 58935
Comments "649978-booked
Pairs_Id 52006
Amount1 -475000.0
Amount2 23607500.0

ACTION "INS"
TRANS_ID 973796

TBL ForwardDeals
ForwardDeals_Id 883798
DealStatus V
InputMode I
CaptureDate "04/05/2009
TradeDate 04/05/2009
Users_Id 63768
Users_Id_Last 0
Folders_Id 63761
Purposes_Id 61987
TypeOfEvent K
BlockNumber 887592
TypeOfInstr_Id 58935
Comments "649978-booked
Pairs_Id 52006
Amount1 -575000.0
Amount2 33607500.0

Please guide ,Thanks in advance
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mail problem (NOT Mail or Mail.app)

When I try to use the CLI mail, I get the following error. What's wrong? Welcome to Darwin! % mail root Subject: test test . EOT % /etc/mail/sendmail.cf: line 81: fileclass: cannot open /etc/mail/local-host-names: Group writable directory Do I just need to change the... (1 Reply)
Discussion started by: chenly
1 Replies

2. Shell Programming and Scripting

mail merge

dear friends plese give me full shell script for mail merge facilityu. i.e. to create a letter file i.e to create data file and report maile merge using shell scripitng. when run the programme ask for fields and store in a file and from another program when run that mail merge file... (3 Replies)
Discussion started by: cvvsnm
3 Replies

3. Shell Programming and Scripting

Merge two files in windows using perl script

Hi I want to merge two or more files using perl in windows only(Just like Paste command in Unix script) . How can i do this.Is ther any single command to do this? Thanks Kunal (1 Reply)
Discussion started by: kunal_dixit
1 Replies

4. Shell Programming and Scripting

Problem using mailx instead of mail in perl program

I have a perl program that uses the mail program to send emails. It works fine but because I want to change the return address on the emails to be different I need to use mailx with the "-r" option. the problem is when I change this line to use mailx I no longer recieve "any" emails. This works... (1 Reply)
Discussion started by: kieranfoley
1 Replies

5. Shell Programming and Scripting

perl merge two files by the time sequence

Hi Guys, i have two files: fileA: 20090611 00:00:11 20090611 00:00:11 20090611 00:00:24 20090611 00:01:10 20090611 07:13:00 fileB: 20090611 00:00:01 20090611 00:00:12 20090611 00:00:24 20090611 00:01:12 20090611 09:13:00 want to make two files into a single file, but follow the... (14 Replies)
Discussion started by: jimmy_y
14 Replies

6. Shell Programming and Scripting

Using Perl to Merge Multiple Lines in a File

I've hunted and hunted but nothing seems to apply to what I need. Any help will be much appreciated! My input file looks like (Unix): marker,allele1,allele2 RS1002244,1,1 RS1002244,1,3 RS1002244,3,3 RS1003719,2,2 RS1003719,2,4 RS1003719,4,4 Most markers are listed 3 times but a few... (2 Replies)
Discussion started by: Peggy White
2 Replies

7. Shell Programming and Scripting

How to merge 2 files based on delimeter in perl?

Hi, I have 2 files. a.txt & b.txt # a.txt contains the following text. apple grapes # b.txt contains the following text. banana pine My question is. (1 Reply)
Discussion started by: vanitham
1 Replies

8. Shell Programming and Scripting

merge multiple tables with perl

Hi everyone, I once again got stuck with merging tables and was wondering if someone could help me out on that problem. I have a number of tab delimited tables which I need to merge into one big one. All tables have the same header but a different number of rows (this could be changed if... (6 Replies)
Discussion started by: TuAd
6 Replies

9. Shell Programming and Scripting

Awk or Perl - to selectively merge two files.

I have two files, these have to be selectively merged into two other files. In addition there will require to be a edit to the last field, where the date format is changed. The first file is a csv file with around 300k lines the data is now nearly 20 years old and I have been asked to move this... (7 Replies)
Discussion started by: gull04
7 Replies

10. Shell Programming and Scripting

E-mail Output Merge Lines for Some Text..

Hi all. This is the content of the text file used for the e-mail: TM ICP-EDW BILLING REGISTER USAGE BREAKDOWN_01062014.csv TM_ICP_EDWH_FICL_13062014.TXT TM_ICP_EDWH_FICL_16062014.TXT TM_ICP_EDW_Detailed Payment Journal Report_13062014.txt TM_ICP_EDW_Detailed Payment Journal... (9 Replies)
Discussion started by: aimy
9 Replies
rate.conf(5)							   isdnlog 4.71 						      rate.conf(5)

NAME
/etc/isdn/rate.conf - rate and provider configuration DESCRIPTION
isdnlog and related programs like isdnrep or isdnrate obtain the information about telephone rates or fees from a rate-file. In addition to the general data from the rate-file it is necessary to provide information about the individual situation. This is the purpose of the configuration file rate.conf. Words below consisting of uppercase letters like RATEFILE refer to the so named setting in the general isdnlog configuration file /etc/isdn/isdn.conf. General Concepts The rate-file contains one or more providers for a country. A provider covers an offer of a telephone company. Usually there are now many telephone companies in a country and most companies offer several different price lists. A provider is identified by provider number and provider variant or sub number. The provider number, short pnum, is commonly used for all offers of one company. The provider variant, short var, is used to number these offers starting from 0. A specific provider is referenced as pnum,var or pnum_var depending on the context. VBN contains the shared leading digits of the carrier selection prefixes. The entire prefix for a provider is specified in the rate-file by the B: tag. In Germany the carrier selection prefix begins with 010 followed by two or three digits which make the pnum ranging from 10 to 199. A mapping like this is not required but common. The overall format of rate.conf is similar to the rate-file, lines starting with tags P:, X:, or Q: may occur in any order and quantity. (Of course, the resulting configuration should make sense.) Provider Booking P:pnum=var Mark the provider specified by pnum and var as booked or active. Only booked providers are taken into account when isdnlog computes the connection costs. Booking also tells isdnlog the provider variant to use if there are more than one. Beside computation of real connections booking also splits the providers in two groups: the booked ones that are available at the specific subscriber line at the not booked ones that are less important for price comparison. One provider in booked group is declared the default provider by setting PRESELECTED to its pnum. This provider is assumed to be used if a connection is made without a carrier selection prefix and no exceptions matching. Exceptions to Provider Selection X:number=pnum X:number=pnumzzone Connections to number will be assigned the booked provider with pnum as provider number regardless of a dialed provider selection prefix or the PRESELECTED setting. zone if present replaces the normal zone selection based on destination codes. Exceptions can also be given in the rate-file. In rate.conf exceptions may become necessary if there different preselected providers for local and distance calls for example or if prese- lection does not apply generally, e.g. not for connections to special numbers. Provider Skipping At least for some countries there are universal rate-files distributed with isdnlog or provided elsewhere. In this case it is desirable to keep the rate-file unmodified so that updates require no further changes beyond installing the new rate-file. If a rate-file aims to cover the telephone market in an entire nation there will be always providers in it which are not available or not suitable for a specific installation. Such providers can be disabled by not booking them but they remain present and may be displayed as overall cheapest provider or the like. Provider skipping completely ignores selected, so called skipped providers, from the rate-file. To be more precise, the effect of skipped provider could also be achieved by deleting its lines starting from its P: tag to the last line before the P: tag of the next provider from the rate-file. Providers to skip can also be configured in the parameter file of isdnlog using the syntax described below in a line starting with skip- Prov= instead of Q:. Q:[!|~]list list := range[;list] range := (*|prov|prov-|-prov|prov-prov)[!|~] prov := pnum[,var] Skipping applies to all providers that are matched by a given range. If var is missing, all providers with pnum are skipped. * matches all providers. Booked providers are not skipped unless ! is given at end of the range or in front of the entire list where it applies to whole line. The ~ can be given alternatively to !. Providers that match such a range are not skipped under any circumstances. Space can occur anywhere in the line after Q:. Example: Q:*; 13,1~; 33-33,1~; 200-299!; 321-323! This skips all not booked providers except 13_1, 33_0, and 33_1. Additionally all providers with a pnum between 200 and 299 or 321 and 323 are skipped. FILES
/etc/isdn/rate.conf This file. RATECONF may be used to specify an alternative rate and provider configuration file. /usr/lib/isdn/rate-CC.dat The rate-file for your country. Replace CC with your two letter country code, e.g. de for Germany. RATEFILE defines the rate-file to use. AUTHOR
Tobias Becker <tobiasb@isdn4linux.de> SEE ALSO
isdnlog(8) rate-files(5) isdn.conf(5) ISDN 4 Linux 3.13 2007/01/05 rate.conf(5)
All times are GMT -4. The time now is 11:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy