Sponsored Content
Top Forums Shell Programming and Scripting Shell script to extract data from csv file Post 302850009 by Vivekit82 on Tuesday 3rd of September 2013 06:05:02 PM
Old 09-03-2013
ok..even if the files are only , separated how can i extract the output as below:

Code:
Static Data Ingested:
Column_1,Column_6,Column_7,% Column_8,Column_9 ,Column_10
viv           5896325,  0.00      ,    0          ,0            ,1

Static Data extracted:

Column_1,Column_2,Column_3,Column_4,Column_6
rms,k2c,08/28/2013,1234566,08/31/2013,5896325,0.00,0,0
SDS,k3c,08/28/2013,589652,08/31/2013,2365896,0.00,0,0

where Static Data Ingested and Static Data extracted are theheadings of the respective records.

Last edited by Scrutinizer; 09-03-2013 at 08:13 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script to Load data into the database using a .csv file and .ctl file

Since i'm new to scripting i'm findind it difficult to code a script. The script has to be an executable with 2 paramters passed to it.The Parameters are 1. The Control file name(.ctl file) 2. The Data file name(.csv file) Does anybody have an idea about it? :confused: (3 Replies)
Discussion started by: Csmani
3 Replies

2. Shell Programming and Scripting

shell-script which extract data from log file

give me a shell-script which extract data from log file on a server by giving date and time as input (for both start time and end time) and it will give the logs generated during the given time as output. (4 Replies)
Discussion started by: abhishek27
4 Replies

3. Shell Programming and Scripting

Help with shell script to extract data from XML file

Hello Scripting Gurus, I need help with extracting data from the XML file using shell script. The data is in a large XML and I need to extract the id values of all completedworkflows. Here is a sample of it. Input and output data is also in the attached text files. <wfregistry>... (5 Replies)
Discussion started by: yajaykumar
5 Replies

4. Shell Programming and Scripting

Exporting data as a CSV file from Unix shell script

Friends...This is the first time i am trying the report generation using shell script... any suggestions are welcome. Is there a way to set the font size & color when i am exporting the data from unix shell script as a CSV file ? The following sample data is saved as a .csv file in the... (2 Replies)
Discussion started by: appu2176
2 Replies

5. Shell Programming and Scripting

need a shell script to extract data from a log file.

If I have a log like : Mon Jul 19 05:07:34 2010; TCP; eth3; 52 bytes; from abc to def Mon Jul 19 05:07:35 2010; UDP; eth3; 46 bytes; from aaa to bbb Mon Jul 19 05:07:35 2010; TCP; eth3; 52 bytes; from def to ghi I will need an output like this : Time abc to def... (1 Reply)
Discussion started by: hitha87
1 Replies

6. Shell Programming and Scripting

How to extract data from csv file

Hello everybody, Here is my problem, I don't know anything about shell programming and my boss is actually asking me to develop a shell script in order to get values in a csv file from a specific date. Here is a sample of the csv file : Date;Enchaînement;Titre;Libellé ;calendrier;Heure début;Heure... (11 Replies)
Discussion started by: freyr
11 Replies

7. Shell Programming and Scripting

Read data from .csv file through shell script & modify

I need to read data from a file called "test.csv" through shell script where the file contains values like name,price,descriptor etc. There are rows where descriptor (& in some rows name) are written as string & other characters like "car_+" OR "bike*" etc where it should contains strings like... (3 Replies)
Discussion started by: raj100
3 Replies

8. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file based on certain conditions

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (1 Reply)
Discussion started by: Vivekit82
1 Replies

9. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 7 columns having values say column 1,column 2.....column 7 as below along with their values. Name, Address,... (7 Replies)
Discussion started by: Vivekit82
7 Replies

10. UNIX for Beginners Questions & Answers

Shell script to extract data in a file

I have this 5GB file, and i want to extract from the file particulars pattern. this is my script: // count=`grep -wc "MSISDN" file_name` k=1 >OUTPUT >OUTPUT_Final while do cat file_name | awk -F":" -v var="$k" '$1=="MSISDN" {m++}m==var{print; exit}' >> OUTPUT cat file_name |awk -F":"... (33 Replies)
Discussion started by: gillesi
33 Replies
Data::Compare(3)					User Contributed Perl Documentation					  Data::Compare(3)

NAME
Data::Compare - compare perl data structures SYNOPSIS
use Data::Compare; my $h1 = { 'foo' => [ 'bar', 'baz' ], 'FOO' => [ 'one', 'two' ] }; my $h2 = { 'foo' => [ 'bar', 'barf' ], 'FOO' => [ 'one', 'two' ] }; my @a1 = ('one', 'two'); my @a2 = ('bar', 'baz'); my %v = ( 'FOO', @a1, 'foo', @a2 ); # simple procedural interface print 'structures of $h1 and \%v are ', Compare($h1, \%v) ? "" : "not ", "identical. "; print 'structures of $h1 and $h2 are ', Compare($h1, $h2, { ignore_hash_keys => [qw(foo)] }) ? '' : 'not ', "close enough to identical. "; # OO usage my $c = new Data::Compare($h1, \%v); print 'structures of $h1 and \%v are ', $c->Cmp ? "" : "not ", "identical. "; # or my $c = new Data::Compare; print 'structures of $h and \%v are ', $c->Cmp($h1, \%v) ? "" : "not ", "identical. "; DESCRIPTION
Compare two perl data structures recursively. Returns 0 if the structures differ, else returns 1. A few data types are treated as special cases: Scalar::Properties objects This has been moved into a plugin, although functionality remains the same as with the previous version. Full documentation is in Data::Compare::Plugins::Scalar::Properties. Compiled regular expressions, eg qr/foo/ These are stringified before comparison, so the following will match: $r = qr/abc/i; $s = qr/abc/i; Compare($r, $s); and the following won't, despite them matching *exactly* the same text: $r = qr/abc/i; $s = qr/[aA][bB][cC]/; Compare($r, $s); Sorry, that's the best we can do. CODE and GLOB references These are assumed not to match unless the references are identical - ie, both are references to the same thing. You may also customise how we compare structures by supplying options in a hashref as a third parameter to the "Compare()" function. This is not yet available through the OO-ish interface. These options will be in force for the *whole* of your comparison, so will apply to structures that are lurking deep down in your data as well as at the top level, so beware! ignore_hash_keys an arrayref of strings. When comparing two hashes, any keys mentioned in this list will be ignored. CIRCULAR STRUCTURES
Comparing a circular structure to itself returns true: $x = $y; $y = $x; Compare([$x, $y], [$x, $y]); And on a sort-of-related note, if you try to compare insanely deeply nested structures, the module will spit a warning. For this to affect you, you need to go around a hundred levels deep though, and if you do that you have bigger problems which I can't help you with ;-) PLUGINS
The module takes plug-ins so you can provide specialised routines for comparing your own objects and data-types. For details see Data::Compare::Plugins. Plugins are *not* available when running in "taint" mode. You may also make it not load plugins by providing an empty list as the argument to import() - ie, by doing this: use Data::Compare (); A couple of functions are provided to examine what goodies have been made available through plugins: plugins Returns a structure (a hash ref) describing all the comparisons made available through plugins. This function is *not* exported, so should be called as Data::Compare::plugins(). It takes no parameters. plugins_printable Returns formatted text EXPORTS
For historical reasons, the Compare() function is exported. If you don't want this, then pass an empty list to import() as explained under PLUGINS. If you want no export but do want plugins, then pass the empty list, and then call the register_plugins class method: use Data::Compare (); Data::Compare->register_plugins; or you could call it as a function if that floats your boat. SOURCE CODE REPOSITORY
<git://github.com/DrHyde/perl-modules-Data-Compare.git> BUGS
Plugin support is not quite finished (see the TODO file for details) but is usable. The missing bits are bells and whistles rather than core functionality. Please report any other bugs either by email to David Cantrell (see below for address) or using rt.cpan.org: <https://rt.cpan.org/Ticket/Create.html?Queue=Data-Compare> AUTHOR
Fabien Tassin <fta@sofaraway.org> Portions by David Cantrell <david@cantrell.org.uk> COPYRIGHT and LICENCE Copyright (c) 1999-2001 Fabien Tassin. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Some parts copyright 2003 - 2013 David Cantrell. Seeing that Fabien seems to have disappeared, David Cantrell has become a co-maintainer so he can apply needed patches. The licence, of course, remains the same. As the "perl licence" is "Artistic or GPL, your choice", you can find them as the files ARTISTIC.txt and GPL2.txt in the distribution. SEE ALSO
perl(1), perlref(1) perl v5.18.2 2013-09-26 Data::Compare(3)
All times are GMT -4. The time now is 04:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy