Concatenating many files based on a specific column contents
Dear all,
I have many files(.csv) in a directory.
I want to concatenate the files which have similar entries in a particular column and save into a new file like result_datetime.csv etc.
One example file is like below.
and one more example is like below.
Here both files have similar entries for col2(Step).
So we need to concatenate these files.
Like this we need to scan all the files in the folder and look for specific column entries and concatenate all similar files.
Hi,
I have a file that has several values seperated by ":"
2006:John:Student:Football:Portugal:Cinema
2006:James:Engineer:Basket:Poland:Theatre
2007:Lucy:Diver:Gymnastic:England:Music
2007:Smith:Plumber:Basket:Spain:Poker
I need make a filter based on the 5th field to find countries that... (1 Reply)
HI,
Your help was great: awk -F":" '$5 ~ /^P/{print }' file
I would like to know what changes need to be done to this line code, so that I can put it in a shell script and call it as the example below.
example: countries that start with chacater 'P'
> country P
Result:
... (0 Replies)
Hi,
I have a file f1 having the contents as below
select (<condn>) from dual
I have another file f2 having the contents as below
1,
2,
3
I want to replace <condn> in f1 with the contents of f2
I tried using sed like this
sed "s:<condn>:`cat f2`:g" f1
The above command resulted in sed:... (3 Replies)
Hello everyone,
I currently have a situation which is causing me some issues for keeping up with certain files. I will explain this to the best of my abilities.
I have a list of files as follows
50_REPORT_1111 - file contains the word Car
50_REPORT_2222 - file contains the word House... (15 Replies)
Hi,
I have a unix file with the below structure -
CustId1 CustName1 CustPhn1 /u/home/xmldata/A000001
CustId2 CustName2 CustPhn2 /u/home/xmldata/A000002
CustId3 CustName3 CustPhn3 /u/home/xmldata/A000003
Then I have another unix directory /u/home/xmldata
This directory has... (3 Replies)
Hi,
I have a tab delimited text file from which I want to cut out specific columns. If the second column equals one, I want to cut out columns 1 and 5 and 6. If the second column equals two, I want to cut out columns 1 and 5 and 7. How do I go about doing that? Thanks! (4 Replies)
Here is my dir structure:
/tmp/dave/myappend.txt
/tmp/dave/dir1/test.txt
/tmp/dave/dir2/test.txt
/tmp/dave/dir3/test.txt
/tmp/dave/dir4/test.txt
I want to append the contents of myappend.txt to the end of each file with the name "test.txt" in all dirs in /tmp/dave/
I have tried this:... (2 Replies)
Good day all.
Using basic UNIX/Linux tools, how would you delete a line based on a character found in column 1?
For example, if the CITY name contains an 'a' or 'A', delete the line:
New York City; New York
Los Angeles; California
Chicago; Illinois
Houston; Texas
Philadelphia;... (3 Replies)
I'm new to shell programming, I have a huge text file in the following format, where columns are separated by single space:
ACA MEX 4O_ $98.00 $127.40 $166.60 0:00 0:00 0 ;
ACA YUL TS_ $300.00 $390.00 $510.00 0:00 0:00 0 ;
ACA YYZ TS_ $300.00 $390.00 $510.00 0:00 0:00 0 ;
ADZ YUL TS_ $300.00... (3 Replies)
Discussion started by: transat
3 Replies
LEARN ABOUT DEBIAN
test::bdd::cucumber::manual::steps
Test::BDD::Cucumber::Manual::Steps(3pm) User Contributed Perl Documentation Test::BDD::Cucumber::Manual::Steps(3pm)NAME
Test::BDD::Cucumber::Manual::Steps - How to write Step Definitions
VERSION
version 0.11
INTRODUCTION
The 'code' part of a Cucumber test-suite are the Step Definition files which match steps, and execute code based on them. This document
aims to give you a quick overview of those.
STARTING OFF
Most of your step files will want to start something like:
#!perl
use strict;
use warnings;
use Test::More;
use Test::BDD::Cucumber::StepFile;
use Method::Signatures;
The fake shebang line gives some hints to syntax highlighters, and "use strict;" and "use warnings;" are hopefully fairly standard at this
point.
Most of my Step Definition files make use of Test::More, but you can use any Test::Builder based testing module. Your step will pass its
pass or fail status back to its harness via Test::Builder - each step is run as if it were its own tiny test file, with its own localized
Test::Builder object.
Test::BDD::Cucumber::StepFile gives us the functions "Given()", "When()", "Then()" and "Step()". These pass the step definitions to the
class loading the step definitions, and specify which Step Verb should be used - "Step()" matches any.
Method::Signatures allows us to use a small amount of syntactic sugar for the step definitions, and gives us the "func()" keyword you'll
see in a minute.
STEP DEFINITIONS
Given qr/I have (d+)/, func ($c) {
$c->stash->{'scenario'}->{'count'} += $1;
}
When "The count is an integer", func ($c) {
$c->stash->{'scenario'}->{'count'} =
int( $c->stash->{'scenario'}->{'count'} );
}
Then qr/The count should be (d+)/, func ($c) {
is( $c->stash->{'scenario'}->{'count'}, $c->matches->[0], "Count matches" );
}
Each of the exported verb functions accept a regular expression (or a string that's used as one), and a coderef. The coderef is passed a
single argument, the Test::BDD::Cucumber::StepContext object. To make this a little prettier, we use Method::Signatures's "func()" keyword
so we're not continually typing: "sub { my $c = shift; ... ".
We will evaluate the regex immediately before we execute the coderef, so you can use $1, $2, $etc, although these are also available via
the StepContext.
NEXT STEPS
How step files are loaded is discussed in Test::BDD::Cucumber::Manual::Architecture, but isn't of much interest. Of far more interest
should be seeing what you have available in Test::BDD::Cucumber::StepContext...
AUTHOR
Peter Sergeant "pete@clueball.com"
LICENSE
Copyright 2011, Peter Sergeant; Licensed under the same terms as Perl
perl v5.14.2 2012-05-20 Test::BDD::Cucumber::Manual::Steps(3pm)