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.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT DEBIAN
anydata::format::htmltable
AnyData::Format::HTMLtable(3pm) User Contributed Perl Documentation AnyData::Format::HTMLtable(3pm)NAME
HTMLtable - tied hash and DBI/SQL access to HTML tables
SYNOPSIS
use AnyData;
my $table = adHash( 'HTMLtable', $filename );
while (my $row = each %$table) {
print $row->{name},"
" if $row->{country} =~ /us|mx|ca/;
}
# ... other tied hash operations
OR
use DBI
my $dbh = DBI->connect('dbi:AnyData:');
$dbh->func('table1','HTMLtable', $filename,'ad_catalog');
my $hits = $dbh->selectall_arrayref( qq{
SELECT name FROM table1 WHERE country = 'us'
});
# ... other DBI/SQL operations
DESCRIPTION
This module allows one to treat the data contained in an HTML table as a tied hash (using AnyData.pm) or as a DBI/SQL accessible database
(using DBD::AnyData.pm). Both the tiedhash and DBI interfaces allow one to read, modify, and create HTML tables from perl data or from
local or remote files.
The module requires that CGI, HTML::Parser and HTML::TableExtract are installed.
When reading the HTML table, this module is essentially just a pass through to Matt Sisk's excellent HTML::TableExtract module.
If no flags are specified in the adTie() or ad_catalog() calls, then TableExtract is called with depth=0 and count=0, in other words it
finds the first row of the first table and treats that as the column names for the entire table. If a flag for 'cols' (column names) is
specified in the adTie() or ad_catalog() calls, that list of column names is passed to TableExtract as a headers parameter. If the user
specifies flags for headers, depth, or count, those are passed directly to TableExtract.
When exporting to an HTMLtable, you may pass flags to specify properties
of the whole table (table_flags), the top row containing the column names
(top_row_flags), and the data rows (data_row_flags). These flags follow
the syntax of CGI.pm table constructors, e.g.:
print adExport( $table, 'HTMLtable', {
table_flags => {Border=>3,bgColor=>'blue'};
top_row_flags => {bgColor=>'red'};
data_row_flags => {valign='top'};
});
The table_flags will default to {Border=>1,bgColor=>'white'} if none
are specified.
The top_row_flags will default to {bgColor=>'#c0c0c0'} if none are
specified;
The data_row_flags will be empty if none are specified.
In other words, if no flags are specified the table will print out with
a border of 1, the column headings in gray, and the data rows in white.
CAUTION: This module will *not* preserve anything in the html file except
the selected table so if your file contains more than the selected table,
you will want to use adTie() or $dbh->func(...,'ad_import') to read the
table and then adExport() or $dbh->func(...,'ad_export') to write
the table to a different file. When using the HTMLtable format, this is the
only way to preserve changes to the data, the adTie() command will *not*
write to a file.
AUTHOR & COPYRIGHT
copyright 2000, Jeff Zucker <jeff@vpservices.com> all rights reserved
perl v5.10.1 2004-08-17 AnyData::Format::HTMLtable(3pm)