Sponsored Content
Top Forums Shell Programming and Scripting Merging 2 lines based on a string Post 302934163 by Karunyam on Thursday 5th of February 2015 04:28:41 AM
Old 02-05-2015
Code:
Line1:vsin : vj005 Acc type : vjs
Line2:Settlement cur : USD trade date :22-01-12
Line3:vjre 15565  1 020765 S  30-01-14 12,000 Vets
Line4: vjre 12678  1 03765   B 30-01-14  2,000 vets
Line5: vsin : vj006 Acc type : cgf
Line6: vjre  1025   1 07654    S 30-01-14. 2,765 vets
..
..

---------- Post updated at 04:28 AM ---------- Previous update was at 04:26 AM ----------

Sorry line 6 is just like line 2 which starts with
Line6: Settlement curr ...
[/CODE]
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

searching and storing unknown number of lines based on the string with a condition

Dear friends, Please help me to resolve the problem below, I have a file with following content: date of file creation : 12 feb 2007 ==================== = name : suresh = city :mumbai #this is a blank line = date : 1st Nov 2005 ==================== few lines of some text this... (7 Replies)
Discussion started by: swamymns
7 Replies

2. Shell Programming and Scripting

Merging lines based on occurances of a particular character in a file

Hi, Is there any way to merge two lines based on specific occurance of a character in a file. I am having a flat file which contains multiple records. Each row in the file should contain specified number of delimiter. For a particular row , if the delimiter count is not matched with... (2 Replies)
Discussion started by: mohan_tuty
2 Replies

3. Shell Programming and Scripting

awk to print lines based on string match on another line and condition

Hi folks, I have a text file that I need to parse, and I cant figure it out. The source is a report breaking down softwares from various companies with some basic info about them (see source snippet below). Ultimately what I want is an excel sheet with only Adobe and Microsoft software name and... (5 Replies)
Discussion started by: rowie718
5 Replies

4. Shell Programming and Scripting

Multi line document to single lines based on occurance of string

Hi Guys, I am new to awk and sed, i am working multiline document, i want to make make that document into SINGLE lines based on occurace of string "dwh". here's the sample of my problem.. dwh123 2563 4562 4236 1236 78956 12394 4552 dwh192 2656 46536 231326 65652 6565 23262 16625623... (5 Replies)
Discussion started by: victor369
5 Replies

5. Shell Programming and Scripting

Merge two non-consecutive lines based on line number or string

This is a variation of an earlier post found here: unixcom/shell-programming-scripting/159821-merge-two-non-consecutive-lines.html User Bartus11 was kind enough to solve that example. Previously, I needed help combining two lines that are non-consecutive in a file. Now I need to do the... (7 Replies)
Discussion started by: munkee
7 Replies

6. Shell Programming and Scripting

Merging Lines based on criteria

Hello, Need help with following scenario. A file contains following text: {beginning of file} New: This is a new record and it is not on same line. Since I have lost touch with script take this challenge and bring all this in one line. New: Hello losttouch. You seem to be struggling... (4 Replies)
Discussion started by: losttouch
4 Replies

7. UNIX for Dummies Questions & Answers

Remove lines in a positional file based on string value

Gurus, I am relatively new to Unix scripting and am struck with a problem in my script. I have positional input file which has a FLAG indicator in at position 11 in every record of the file. If the Flag has value =Y, then the record from the input needs to be written to a new file.However if... (3 Replies)
Discussion started by: gsam
3 Replies

8. UNIX for Dummies Questions & Answers

Merging lines based on one column

Hi, I have a file which I'd like to merge lines based on duplicates in one column while keeping the info for other columns. Let me simplify it by an example: File ESR1 ANASTROZOLE NA FDA_approved ESR1 CISPLATIN NA FDA_approved ESR1 DANAZOL agonist NA ESR1 EXEMESTANE NA FDA_approved... (3 Replies)
Discussion started by: JJ001
3 Replies

9. Shell Programming and Scripting

Merging multiple lines to columns with awk, while inserting commas for missing lines

Hello all, I have a large csv file where there are four types of rows I need to merge into one row per person, where there is a column for each possible code / type of row, even if that code/row isn't there for that person. In the csv, a person may be listed from one to four times... (9 Replies)
Discussion started by: RalphNY
9 Replies

10. UNIX for Beginners Questions & Answers

Merging multiple lines into single line based on one column

I Want to merge multiple lines based on the 1st field and keep into single record. SRC File: AAA_POC_DB.TAB1 AAA_POC_DB.TAB2 AAA_POC_DB.TAB3 AAA_POC_DB.TAB4 BBB_POC_DB.TAB1 BBB_POC_DB.TAB2 CCC_POC_DB.TAB6 OUTPUT ----------------- 'AAA_POC_DB','TAB1','TAB2','TAB3','TAB4'... (10 Replies)
Discussion started by: raju2016
10 Replies
Format(3pm)						User Contributed Perl Documentation					       Format(3pm)

NAME
Locale::Currency::Format - Perl functions for formatting monetary values SYNOPSIS
use Locale::Currency::Format; $amt = currency_format('USD', 1000); # => 1,000.00 USD $amt = currency_format('EUR', 1000, FMT_COMMON); # => EUR1.000,00 $amt = currency_format('USD', 1000, FMT_SYMBOL); # => $1,000.00 $sym = currency_symbol('USD'); # => $ $sym = currency_symbol('GBP', SYM_HTML); # => &#163; $decimals = decimal_precision('USD'); # => 2 $decimals = decimal_precision('BHD'); # => 3 $thou_sep = thousands_separator('USD'); # => , $thou_sep = thousands_separator('EUR'); # => . $dec_sep = decimal_separator('USD'); # => . $dec_sep = decimal_separator('EUR'); # => , currency_set('USD', '#.###,## $', FMT_COMMON); # => set custom format currency_format('USD', 1000, FMT_COMMON); # => 1.000,00 $ currency_set('USD'); # => reset default format The following example illustrates how to use Locale::Currency::Format with Mason. Skip it if you are not interested in Mason. A simple Mason component might look like this: Total: <% 123456789, 'eur' |c %> <%init> use Locale::Currency::Format; $m->interp->set_escape(c => &escape_currency); sub escape_currency { my ($amt, $code) = ${$_[0]} =~ /(.*?)([A-Za-z]{3})/; ${$_[0]} = currency_format($code, $amt, FMT_HTML); } </%init> DESCRIPTION
Locale::Currency::Format is a light-weight Perl module that enables Perl code to display monetary values in the formats recognized internationally and/or locally. "currency_format(CODE, AMOUNT [, FORMAT])" currency_format takes two mandatory parameters, namely currency code and amount respectively, and optionally a third parameter indicating which format is desired. Upon failure, it returns undef and an error message is stored in $Locale::Currency::Format::error. CODE A 3-letter currency code as specified in ISO 4217. Note that old code such as GBP, FRF and so on can also be valid. AMOUNT A numeric value. FORMAT There are five different format options FMT_STANDARD, FMT_COMMON, FMT_SYMBOL, FMT_HTML and FMT_NAME. If it is omitted, the default format is FMT_STANDARD. FMT_STANDARD Ex: 1,000.00 USD, 1.000.000,00 EUR FMT_SYMBOL Ex: $1,000.00 FMT_COMMON Ex: 1.000 Dong (Vietnam), BEF 1.000 (Belgium) FMT_HTML Ex: &#xA3;1,000.00 (pound-sign HTML escape) FMT_NAME Ex: 1,000.00 US Dollar NOTE: By default the trailing zeros after the decimal point will be added. To turn it off, do a bitwise C<or> of FMT_NOZEROS with one of the five options above. Ex: FMT_STANDARD | FMT_NOZEROS will give 1,000 USD "currency_symbol(CODE [, TYPE])" For conveniences, the function currency_symbol is provided for currency symbol lookup given a 3-letter currency code. Optionally, one can specify which format the symbol should be returned - Unicode-based character or HTML escape. Default is a Unicode-based character. Upon failure, it returns undef and an error message is stored in $Locale::Currency::Format::error. CODE A 3-letter currency code as specified in ISO 4217 TYPE There are two available types SYM_UTF and SYM_HTML SYM_UTF returns the symbol (if exists) as an Unicode character SYM_HTML returns the symbol (if exists) as a HTML escape "decimal_precision(CODE)" For conveniences, the function decimal_precision is provided to lookup the decimal precision for a given 3-letter currency code. Upon failure, it returns undef and an error message is stored in $Locale::Currency::Format::error. CODE A 3-letter currency code as specified in ISO 4217 "decimal_separator(CODE)" For conveniences, the function decimal_separator is provided to lookup the decimal separator for a given 3-letter currency code. Upon failure, it returns undef and an error message is stored in $Locale::Currency::Format::error. CODE A 3-letter currency code as specified in ISO 4217 "thousands_separator(CODE)" For conveniences, the function thousands_separator is provided to lookup the thousands separator for a given 3-letter currency code. Upon failure, it returns undef and an error message is stored in $Locale::Currency::Format::error. CODE A 3-letter currency code as specified in ISO 4217 "currency_set(CODE [, TEMPLATE, FORMAT])" currency_set can be used to set a custom format for a currency instead of the provided format. For example, in many non-English speaking countries, the US dollars might be displayed as 2.999,99 $ instead of the usual $2,999.99. In order to accomplish this, one will need to do as follows: use Locale::Currency::Format qw(:default $error); my $currency = 'USD'; my $template = '#.###,## $'; if (currency_set($currency, $template, FMT_COMMON)) { print currency_format($currency, 2999.99, FMT_COMMON), " "; } else { print "cannot set currency format for $currency: $error "; } The arguments to currency_set are: CODE A 3-letter currency code as specified in ISO 4217 TEMPLATE A template in the form #.###,##$, #.### kr, etc. If a unicode character is used, make sure that the template is double-quoted. Ex: currency_set('GBP', "x{00A3}#,###.##", FMT_SYMBOL) If an HTML symbol is wanted, escape its equivalent HTML code. Ex: currency_set('GBP', '&#x00A3;#,###.##', FMT_HTML) FORMAT This argument is required if TEMPLATE is present. The formats FMT_SYMBOL, FMT_COMMON, FMT_HTML are accepted. NOTE! FMT_STANDARD and FMT_NAME will always be in the form <amount><space><code|name> such as 1,925.95 AUD. Hence, currency_set returns an error if FMT_STANDARD or FMT_NAME is specified as FORMAT. With FMT_COMMON, you can always achieve what you would have done with FMT_STANDARD and FMT_NAME, as follows my $amt = 1950.95; currency_set('USD', 'USD #.###,##', FMT_COMMON); print currency_format('USD', $amt, FMT_COMMON); # USD 1,950.95 currency_set('USD', 'US Dollar #.###,##', FMT_COMMON); print currency_format('USD', $amt, FMT_COMMON); # US Dollar 1,950.95 Invoking currency_set with one argument will reset all formats to their original settings. For example currency_set('USD') will clear all previous custom settings for the US currency (ie. FMT_SYMBOL, FMT_HTML, FMT_COMMON). A WORD OF CAUTION Please be aware that some currencies might have missing common format. In that case, currency_format will fall back to FMT_STANDARD format. Also, be aware that some currencies do not have monetary symbol. As countries merge together or split into smaller ones, currencies can be added or removed by the ISO. Please help keep the list up to date by sending your feedback to the email address at the bottom. To see the error, examine $Locale::Currency::Format::error use Locale::Currency::Format; my $value = currency_format('USD', 1000); print $value ? $value : $Locale::Currency::Format::error OR use Locale::Currency::Format qw(:DEFAULT $error); my $value = currency_format('USD', 1000); print $value ? $value : $error Lastly, please refer to perluniintro and perlunicode for displaying Unicode characters if you intend to use FMT_SYMBOL and currency_symbol. Otherwise, it reads "No worries, mate!" SEE ALSO
Locale::Currency, Math::Currency, Number::Format, perluniintro, perlunicode BUGS
If you find any inaccurate or missing information, please send your comments to tnguyen@cpan.org. Your effort is certainly appreciated! CONTRIBUTOR(S) James Kiser <james.kiser@gmail.com> AUTHOR
Tan D Nguyen <tnguyen@cpan.org> COPYRIGHT
This library is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License. perl v5.12.4 2011-07-11 Format(3pm)
All times are GMT -4. The time now is 03:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy