Sponsored Content
Operating Systems Linux Ubuntu Merging strings that have identical rownames in a dataframe Post 302882571 by Alyaa on Wednesday 8th of January 2014 01:42:37 AM
Old 01-08-2014
Merging strings that have identical rownames in a dataframe

Hi

I have a data frame with repeated names in column 1, and different descriptors in column 2. I want to merge/cat strings that have same entry in column 1 into one row with any separator.

Example for input:

Code:
Cvel_1        KOG0155
Cvel_1        KOG0306
Cvel_1        KOG3259
Cvel_1        KOG0931
Cvel_1        KOG3638
Cvel_1        KOG0956

Example for desired output:

HTML Code:
Cvel_1 KOG0155, KOG0306, KOG3259, KOG0931, KOG0956
Thanks a lot
Alyaa
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace 2 identical strings on different lines

I am looking to replace two or more strings on different lines using sed, but not with the same variable. IE # cat xxx.file <abc> abc def ghi abc def ghi abc def ghi currently I can only change each line with the same pattern: # sed -e '/<abc>/!s/abc\(.*\)/jkl mno/' xxx.file abc jkl mno... (3 Replies)
Discussion started by: prkfriryce
3 Replies

2. Shell Programming and Scripting

count identical strings print last row and count

I have a sorted file like: Apple 3 Apple 5 Apple 8 Banana 2 Banana 3 Grape 31 Orange 7 Orange 13 I'd like to search $1 and if $1 is not the same as $1 in the previous row print that row and print the number of times $1 was found. so the output would look like: Apple 8 3 Banana... (2 Replies)
Discussion started by: dcfargo
2 Replies

3. Shell Programming and Scripting

Using Bash/Sed to delete between identical strings

Hi. I'm hoping that someone can help me with a bash script to delete a block of lines from a file. What I want to do is delete every line between two stings that are the same, including the line the first string is on but not the second. (Marked lines to match with !) For example if I... (2 Replies)
Discussion started by: Zykr
2 Replies

4. SuSE

finding and removing block of identical strings

i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings... for example the awk code removing consecutive identical word is:... (2 Replies)
Discussion started by: cocostaec
2 Replies

5. Programming

finding and removing block of identical strings

i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings... for example the awk code removing consecutive identical word is:... (2 Replies)
Discussion started by: cocostaec
2 Replies

6. Shell Programming and Scripting

finding and removing block of identical strings

i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings... for example the awk code removing consecutive identical word is:... (2 Replies)
Discussion started by: cocostaec
2 Replies

7. Programming

Grep part of dataframe in R?

Seems not very post about R language. Here is one: How to grep a sublist of a list like grep -f in unix? say I have a dataframe ID v1 v2 v3 A 1 3 4 B 4 5 6 C 7 8 9 D 1 3 4 E 1 3 3 F 2 4 5 and I only need ID v1 v2 v3 A 1 3 4 C 7 8 9 E 1 3 3 F 2 4 5 by like grep... (2 Replies)
Discussion started by: yifangt
2 Replies

8. Shell Programming and Scripting

Merging strings which have deviation in frequency

Dear all, I need a little help. I am working on a frequency driven database in which the structure is as under: headword=gloss<space>Frequency The data which I am working with has dupes i.e. the Headword is repeated more than once with a different gloss variant on the right hand side and... (8 Replies)
Discussion started by: gimley
8 Replies

9. Shell Programming and Scripting

Print text between 2 identical strings

hey, i m having a hard time trying to print only the first occurrence between 2 idenicale strings. for the following output: please help me im a noob please im a noob help me noob please help me im a noob please im a noob help me noob (3 Replies)
Discussion started by: boaz733
3 Replies

10. UNIX for Beginners Questions & Answers

Remove duplicates in a dataframe (table) keeping all the different cells of just one of the columns

Hello all, I need to filter a dataframe composed of several columns of data to remove the duplicates according to one of the columns. I did it with pandas. In the main time, I need that the last column that contains all different data ( not redundant) is conserved in the output like this: A ... (5 Replies)
Discussion started by: pedro88
5 Replies
DB2_FETCH_OBJECT(3)							 1						       DB2_FETCH_OBJECT(3)

db2_fetch_object - Returns an object with properties representing columns in the fetched row

SYNOPSIS
object db2_fetch_object (resource $stmt, [int $row_number = -1]) DESCRIPTION
Returns an object in which each property represents a column returned in the row fetched from a result set. PARAMETERS
o $stmt - A valid stmt resource containing a result set. o $row_number - Requests a specific 1-indexed row from the result set. Passing this parameter results in a PHP warning if the result set uses a forward-only cursor. RETURN VALUES
Returns an object representing a single row in the result set. The properties of the object map to the names of the columns in the result set. The IBM DB2, Cloudscape, and Apache Derby database servers typically fold column names to upper-case, so the object properties will reflect that case. If your SELECT statement calls a scalar function to modify the value of a column, the database servers return the column number as the name of the column in the result set. If you prefer a more descriptive column name and object property, you can use the AS clause to assign a name to the column in the result set. Returns FALSE if no row was retrieved. EXAMPLES
Example #1 A db2_fetch_object(3) example The following example issues a SELECT statement with a scalar function, RTRIM, that removes whitespace from the end of the column. Rather than creating an object with the properties "BREED" and "2", we use the AS clause in the SELECT statement to assign the name "name" to the modified column. The database server folds the column names to upper-case, resulting in an object with the properties "BREED" and "NAME". <?php $conn = db2_connect($database, $user, $password); $sql = "SELECT breed, RTRIM(name) AS name FROM animals WHERE id = ?"; if ($conn) { $stmt = db2_prepare($conn, $sql); db2_execute($stmt, array(0)); while ($pet = db2_fetch_object($stmt)) { echo "Come here, {$pet->NAME}, my little {$pet->BREED}!"; } db2_close($conn); } ?> The above example will output: Come here, Pook, my little cat! SEE ALSO
db2_fetch_array(3), db2_fetch_assoc(3), db2_fetch_both(3), db2_fetch_row(3), db2_result(3). PHP Documentation Group DB2_FETCH_OBJECT(3)
All times are GMT -4. The time now is 10:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy