03-25-2013
Thanks Anbu
Hello Thanks Anbu,
the f1.gz output is slightly modified , the script given by is working if there is no space after comma.
gzcat f1.gz | more
< Aravind, 33, chennai, 09091980, , , , , , , surfing>
< Swapnil, 32, bhopal, 01121981, , , , , , , cricket>
after comma there is space . how to modify the code for the same.
one more thing is it possible to recreate output with the same file name with changes in the code :-)
if yes please tell the same it would be of great help.
Last edited by aravindj80; 03-25-2013 at 08:06 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
What is the command to count lines in a files, but ignore blank lines and commented lines?
I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end.
Here is an example of what I would like my... (6 Replies)
Discussion started by: kthatch
6 Replies
2. Shell Programming and Scripting
$ cat log.txt
Name Age Sex Lcation nfld alias xsd
CC 25 M XYZ asx KK Y
BB 21 F XAS awe SS N
SD 21 M AQW rty SD A
How can I replace the column with header "Lcation" with the column with header "alias" and delete the "alias" column?
so that the final output will become:
Name Age Sex... (10 Replies)
Discussion started by: jkl_jkl
10 Replies
3. UNIX for Dummies Questions & Answers
I have a data set that has 4 columns, I want to know if I can delete duplicate lines while ignoring one of the columns, for example
10 chr1 ASF 30
15 chr1 ASF 20
5 chr1 ASF 30
6 chr2 EBC 15
4 chr2 EBC 30
...
I want to know if I can delete duplicate lines while ignoring column 1, so the... (5 Replies)
Discussion started by: japaneseguitars
5 Replies
4. Shell Programming and Scripting
Hi All,
I have a file example.csv which looks like this
GrpID,TargetID,Signal,Avg_Num
CSCH74_1_1,2007,61,256
CSCH74_1_1,212007,647,679
CSCH74_1_1,12007,3,32
CSCH74_1_1,207,299,777
I want the output as
GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num
CSCH74_1_1,2007,61,256... (4 Replies)
Discussion started by: Vavad
4 Replies
5. UNIX for Dummies Questions & Answers
Hi All,
I have a file example.csv which looks like this
GrpID,TargetID,Signal,Avg_Num
CSCH74_1_1,2007,61,256
CSCH74_1_1,212007,647,679
CSCH74_1_1,12007,3,32
CSCH74_1_1,207,299,777
I want the output as
GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num
CSCH74_1_1,2007,61,256... (1 Reply)
Discussion started by: Vavad
1 Replies
6. UNIX for Dummies Questions & Answers
Friends,
I need help with the following in UNIX.
Merge all csv files in one folder considering only 1 header row and ignoring header of all other files.
FYI - All files are in same format and contains same headers.
Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies
7. Shell Programming and Scripting
Hi,
I have an input like this
1 2 3 4
2 3 4 5
4 5 6 7
I would like to count the no. of columns and print a header with a prefix "Col".
I would also like to count the no. of rows and print as first column with each line number with a prefix "Row"
So, my output would be
... (2 Replies)
Discussion started by: jacobs.smith
2 Replies
8. Shell Programming and Scripting
Hello,
I am trying to store sum of a column as a new column inside a file but have to find the column names dynamically
I/p
c1,c2,c3,c4,c5
10,20,30,40,50
20,30,40,50,60
If i want to find sum only column c1, c3 and output it as c6,c7
O/p
c1,c2,c3,c4,c5,c6,c7
10,20,30,40,50,30,70... (6 Replies)
Discussion started by: mkathi
6 Replies
9. UNIX for Beginners Questions & Answers
I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies
10. Shell Programming and Scripting
I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty.
I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies
LEARN ABOUT PHP
mongodbref
MONGODBREF(3) 1 MONGODBREF(3)
The MongoDBRef class
INTRODUCTION
This class can be used to create lightweight links between objects in different collections.
Motivation: Suppose we need to refer to a document in another collection. The easiest way is to create a field in the current document. For
example, if we had a "people" collection and an "addresses" collection, we might want to create a link between each person document and an
address document:
Example #1
Linking documents
<?php
$people = $db->people;
$addresses = $db->addresses;
$myAddress = array("line 1" => "123 Main Street",
"line 2" => null,
"city" => "Springfield",
"state" => "Vermont",
"country" => "USA");
// save the address
$addresses->insert($myAddress);
// save a person with a reference to the address
$me = array("name" => "Fred", "address" => $myAddress['_id']);
$people->insert($me);
?>
Then, later on, we can find the person's address by querying the "addresses" collection with the MongoId we saved in the "people" collec-
tion.
Suppose now that we have a more general case, where we don't know which collection (or even which database) contains the referenced docu-
ment. MongoDBRef is a good choice for this case, as it is a common format that all of the drivers and the database understand.
If each person had a list of things they liked which could come from multiple collections, such as "hobbies", "sports", "books", etc., we
could use MongoDBRefs to keep track of what "like" went with what collection:
Example #2
Creating MongoDBRef links
<?php
$people = $db->selectCollection("people");
// model trains are in the "hobbies" collection
$trainRef = MongoDBRef::create("hobbies", $modelTrains['_id']);
// soccer is in the "sports" collection
$soccerRef = MongoDBRef::create("sports", $soccer['_id']);
// now we'll know what collections the items in the "likes" array came from when
// we retrieve this document
$people->insert(array("name" => "Fred", "likes" => array($trainRef, $soccerRef)));
?>
Database references can be thought of as hyperlinks: they give the unique address of another document, but they do not load it or automat-
ically follow the link/reference.
A database reference is just a normal associative array, not an instance of MongoDBRef, so this class is a little different than the other
data type classes. This class contains exclusively static methods for manipulating database references.
CLASS SYNOPSIS
MongoDBRef
MongoDBRef
Methods
o publicstatic array MongoDBRef::create (string $collection, mixed $id, [string $database])
o publicstatic array MongoDBRef::get (MongoDB $db, array $ref)
o publicstatic bool MongoDBRef::isRef (mixed $ref)
SEE ALSO
MongoDB core docs on databases references.
PHP Documentation Group MONGODBREF(3)