Sponsored Content
Top Forums Shell Programming and Scripting Find values in multiple csv files Post 302751625 by RudiC on Friday 4th of January 2013 08:01:44 AM
Old 01-04-2013
Large numbers contain thousands-separator ",", so field separator needs to be ","If your awk version allows for that, try
Code:
awk ' NR==1 {split ($0, Hd); next}
      $19==RefNo {print Hd[ 6]":",  $6;
                  print Hd[ 7]":",  $7;
                  print Hd[22]":", $22;
                  print Hd[23]":", $23;
                  print Hd[24]":", $24;
                  print Hd[26]":", $26 }
    ' FS="\",\""  RefNo=619125 file
Invoice Number: 933234679
Invoice Date: 28-Dec-2012
POD Date: 20121221
POD Time: 1029
POD Name: .DABULEVICIU
Ship Date: 20121214

If it does not, remove thousands-separator first using sed, and then use comma as FS:
Code:
$ sed 's/,\(...\.\)/\1/g' file |
awk -F, '{gsub ("\"","")}
         NR==1 {split ($0, Hd); next}
         $19==RefNo {   print Hd[ 6]":",  $6;
                        print Hd[ 7]":",  $7;
                        print Hd[22]":", $22;
                        print Hd[23]":", $23;
                        print Hd[24]":", $24;
                        print Hd[26]":", $26 }
        '  RefNo=619125

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to compare two csv files values and write into another csv file

Hi all, Am new to scripting. So i just need your ideas to help me out. Here goes my requirement. I have two csv files 1.csv 2.csv abc,1.24 abc,1 def,2.13 def,1 I need to compare the first column of 1.csv with 2.csv and if matches then need to compare... (2 Replies)
Discussion started by: chinnahyd
2 Replies

2. Shell Programming and Scripting

Duplicate rows in CSV files based on values

I want to duplicate a row if found two or more values in a particular column for corresponding row which is delimitted by comma. Input abc,line one,value1 abc,line two, value1, value2 abc,line three,value1 needs to converted to abc,line one,value1 abc,line two, value1 abc,line... (8 Replies)
Discussion started by: Incrediblian
8 Replies

3. Shell Programming and Scripting

Need to compare values on two CSV files

:( Hello, Having a problem with reading two files using awk/nawk, am new to both them. I need to compare field values between two csv files and arrange for an appropriate output if both the values are equal or not for each feild. $cat File1.csv... (4 Replies)
Discussion started by: pgop
4 Replies

4. Shell Programming and Scripting

Duplicate rows in CSV files based on values

I am new to this forum and this is my first post. I am looking at an old post with exactly the same name. Can not paste URL because I do not have 5 posts My requirement is exactly opposite. I want to get rid of duplicate rows and try to append the values of columns in those rows ... (10 Replies)
Discussion started by: vbhonde11
10 Replies

5. Shell Programming and Scripting

Copying multiple csv files

Hi, I have mutiple csv files at server1 at /apps/test/data. I needed a script that would copy these csv files from server1 at /usr/data, put them in server2,archive the earlier files that were present in server2 before removing those already present. Kindly help. (2 Replies)
Discussion started by: Alok Ranjan
2 Replies

6. Shell Programming and Scripting

Field validations in multiple files CSV

Hi, I am regular reader of this forum. My advanced thanks to everyone. Below given are the sample files INDATA (Main data) Fild1Çfld2Çfld3….. Fild1Çfld2Çfld3….. Fild1Çfld2Çfld3….. Fild1Çfld2Çfld3….. Fild1Çfld2Çfld3….. . . N records (140000) eg GRPDATA (Reference file) (2 Replies)
Discussion started by: hyperion.krish
2 Replies

7. UNIX Desktop Questions & Answers

How do you [e]grep for multiple values within multiple files?

Hi I'm sure there's a way to do this, but I ran out of caffeine/talent before getting the answer in a long winded alternate way (don't ask ;) ) The task I was trying to do was scan a directory of files and show only files that contained 3 values: I940 5433309 2181 I tried many variations... (4 Replies)
Discussion started by: callumw
4 Replies

8. Shell Programming and Scripting

How to generate a csv files by separating the values from the input file based on position?

Hi All, I need help for doing the following. I have a input file like: aaaaaaaaaabbbbbbbbbbbbbbbbbbbb cccbbbbbaaaaaadddddaaaabbbbbbb now I am trying to generate a output csv file where i will have for e.g. 0-3 chars of each line as the first column in the csv, 4-10 chars of the line as... (3 Replies)
Discussion started by: babom
3 Replies

9. UNIX for Beginners Questions & Answers

Check for null values in a columns. I have dozen of CSV files in a directory.

Hi Folks, I'm trying to write a simple file sanity check script. I have a directory with dozen CSV files containing id,edname,firstname,lastname,suffix,email. I like to write a awk script to check if first field contain a number and is not empty. and fields number 3,4 & 6 are not empty and... (3 Replies)
Discussion started by: dc34684
3 Replies

10. UNIX for Beginners Questions & Answers

Export Oracle multiple tables to multiple csv files using UNIX shell scripting

Hello All, just wanted to export multiple tables from oracle sql using unix shell script to csv file and the below code is exporting only the first table. Can you please suggest why? or any better idea? export FILE="/abc/autom/file/geo_JOB.csv" Export= `sqlplus -s dev01/password@dEV3... (16 Replies)
Discussion started by: Hope
16 Replies
Date::Language::Bulgarian(3)				User Contributed Perl Documentation			      Date::Language::Bulgarian(3)

NAME
Date::Language::Bulgarian - localization for Date::Format DESCRIPTION
This is Bulgarian localization for Date::Format. It is important to note that this module source code is in utf8. All strings which it outputs are in utf8, so it is safe to use it currently only with English. You are left alone to try and convert the output when using different Date::Language::* in the same application. This should be addresed in the future. SYNOPSIS
use strict; use warnings; use Date::Language; local $=$/; my $template ='%a %b %e %T %Y (%Y-%m-%d %H:%M:%S)'; my $time=1290883821; #or just use time(); my @lt = localtime($time); my %languages = qw(English GMT German EEST Bulgarian EET); binmode(select,':utf8'); foreach my $l(keys %languages){ my $lang = Date::Language->new($l); my $zone = $languages{$l}; print $/. "$l $zone"; print $lang->time2str($template, $time); print $lang->time2str($template, $time, $zone); print $lang->strftime($template, @lt); } AUTHOR
Krasimir Berov (berov@cpan.org) COPYRIGHT
Copyright (c) 2010 Krasimir Berov. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2010-12-15 Date::Language::Bulgarian(3)
All times are GMT -4. The time now is 05:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy