#!/usr/bin/perl -w use strict; use Text::CSV_XS; use IO::File; my $filename = 'hdi.csv'; my $column_to_search = 1; my $wanted_value = 'Sweden'; my $csv = Text::CSV_XS->new({binary=>1}); my $fh = IO::File->new($filename) or die $!; while (my $cols = $csv->getline($fh)) { last unless @$cols; next unless defined $cols->[$column_to_search] and $cols->[$column_to_search] eq $wanted_value; for (0,1,3) { $cols->[$_] = '' unless defined $cols->[$_]; } print join(' ',$cols->[0],$cols->[1],$cols->[3]),"\n"; }
In reply to Re^3: Extracting data from each line that matches a email address from a Log file (Tab delimited)
by jZed
in thread Extracting data from each line that matches a email address from a Log file (Tab delimited)
by Motomo94
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |