01-25-2012
[Solved] Column manipulation
Hi Everyone,
I was wondering if someone could help me to transform my data into a format I need.
Here is an example of what my data looks like
HTML Code:
E F G H
A 1 2 3 4
B 5 6 7 8
C 9 1 2 3
D 4 5 6 7
and this is what I would need it to look like:
HTML Code:
AE 1
BE 5
CE 9
DE 4
AF 2
BF 6
CF 1
DF 5
etc
Basically, I need to take every column and put it under each other.
I've tried doing it with awk by creating separate files for each column and then combine them by using cat, but it takes a lot of time and a lot of temporary files.
Many thanks for your help and time in advance!
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have an input file in which I need to add a column with the value of part of another column.
I.e. I have the following line (example, not the actual data):
field1,field2,field3,test12,field5,field6I need to get the last two characters of the 4th field, and add them at the end as a... (5 Replies)
Discussion started by: Subbeh
5 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I have a tab delimited text file where the first two columns equal numbers. I want to delete all rows where the value in the first column equals the second column. How do I go about doing that? Thanks!
Input:
1 1 ABC DEF
2 2 IJK LMN
1 2 ZYX OPW
Output:
1 2 ZYX OPW (2 Replies)
Discussion started by: evelibertine
2 Replies
3. Shell Programming and Scripting
hello,
I have a file as follows:
F0100010 A C F0100040 A G BTA-28763-no-rs 77.2692
F0100020 A G F0100030 A T BTA-29334-no-rs 11.4989
F0100030 A T F0100020 A G BTA-29515-no-rs 127.006
F0100040 A G F0100010 A C BTA-29644-no-rs 7.29827
F0100050 A... (9 Replies)
Discussion started by: Homa
9 Replies
4. UNIX for Dummies Questions & Answers
Hello Unix.com
How can I sort from a large email list only the emails that finish with .ca domain?
cat <list> | grep "\.ca\b" >> <new list> isnt working perfectly.
Any tips?
Best regards, Galford D. Weller (2 Replies)
Discussion started by: galford
2 Replies
5. Shell Programming and Scripting
Hello,
I was wondering how I could change this input:
cat f1
to produce this output:
As you can tell, I have several unsorted repeating strings in col1 of the input file. Each of these strings has an associated word in col2. Col2 has a total of 4 possible words (go, stop,... (3 Replies)
Discussion started by: verse123
3 Replies
6. Shell Programming and Scripting
Hello, I am a very novice user of awk, I have a set of files named file001, file002, file003, file004, etc., each contains four fields (columns of data) separated each by a uneven number of spaces. I want to substitute those spaces by a TAB, so I am using this line of awk script:
awk -v OFS="\t"... (4 Replies)
Discussion started by: jaldo0805
4 Replies
7. Shell Programming and Scripting
Hallo Team,
I have a .csv file. I would like to have another column called Prefix. Under column Prefix i would like to have the first 3 numbers from the theird column.
Other Licenced Operator Alpha Code Numbering Per minute Interconnect Fee per rate group (R Excluding VAT) ... (4 Replies)
Discussion started by: kekanap
4 Replies
8. Shell Programming and Scripting
Hallo Team,
I need your help. I have a file that has two colums. See sample below:
105550 0.28
105550 0.24
125550 0.28
125550 0.24
215650 0.28
215650 0.24
315550 0.28
315550 0.24
335550 0.28
335550 0.24
40555 0.21
40555 0.17
415550 0.21
415550 0.17
43555 0.21
43555 0.17 (5 Replies)
Discussion started by: kekanap
5 Replies
9. UNIX for Advanced & Expert Users
In a space delimited file how would you go about removing 2 and 3 column of a file and add "word" to the first column of the file in both awk and vi? (2 Replies)
Discussion started by: cokedude
2 Replies
10. UNIX for Dummies Questions & Answers
Hi,
I's like to ask for help with the following question:
this is an example file:
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
I need to have it re-arranged in the following manner: first 2 columns, zero, zero, last two columns, columns 3 to... (6 Replies)
Discussion started by: zajtat
6 Replies
LEARN ABOUT DEBIAN
html::microformats::documentation::notes
HTML::Microformats::Documentation::Notes(3pm) User Contributed Perl Documentation HTML::Microformats::Documentation::Notes(3pm)
NAME
HTML::Microformats::Documentation::Notes - misc usage and design notes
NOTES
Byzantine Internals
The internals of HTML::Microformats are pretty complicated - best to steer clear of them. Here are three usage patterns that mostly avoid
dealing with the internals:
o Parse a page and use it as a single RDF graph.
A page can be parsed into an RDF::Trine::Model and queried using SPARQL.
use HTML::Microformats;
use LWP::Simple qw[get];
use RDF::Query;
my $page = 'http://example.net/';
my $graph = HTML::Microformats
->new_document(get($page), $page)
->assume_all_profiles
->parse_microformats
->model;
my $query = RDF::Query->new(<<SPARQL);
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?friendname ?friendpage
WHERE {
<$page> ?p ?friendpage .
?person foaf:name ?friendname ;
foaf:page ?friendpage .
FILTER (
isURI(?friendpage)
&& isLiteral(?friendname)
&& regex(str(?p), "^http://vocab.sindice.com/xfn#(.+)-hyperlink")
)
}
SPARQL
my $results = $query->execute($graph);
while (my $result = $results->next)
{
printf("%s <%s>
",
$result->{friendname}->literal_value,
$result->{friendpage}->uri,
);
}
o Use the data method on each object.
The "data" method on microformat objects returns a hashref of useful data.
use HTML::Microformats;
use LWP::Simple qw[get];
my $page = 'http://example.net/';
my @xfn_objs = HTML::Microformats
->new_document(get($page), $page)
->assume_all_profiles
->parse_microformats
->objects('XFN');
while (my $xfn = shift @xfn_objs)
{
printf("%s <%s>
",
$xfn->data->{title},
$xfn->data->{href},
);
}
(If you're wondering why the second example's simpler it's because it returns somewhat dumber data.)
o Convert to other formats.
Various microformat objects have "to_foo" methods allowing the data to be exported in various formats..
use HTML::Microformats;
use LWP::Simple qw[get];
my $page = 'http://example.net/';
my @hcards = HTML::Microformats
->new_document(get($page), $page)
->assume_all_profiles
->parse_microformats
->objects('hCard');
print $_->to_vcard foreach @hcards;
Methods available are:
o "to_vcard" (hCard objects)
Exports as vCard 3.0.
o "to_vcard4" (hCard objects)
Exports as vCard 4.0.
o "to_vcard4_xml" (hCard objects)
Exports as vCard XML.
o "to_icalendar" (hCalendar, hEvent, hTodo, hFreebusy, hAlarm and hEntry objects)
Exports as iCalendar.
o "to_atom" (hAtom and hEntry objects)
Exports as Atom 1.0.
o "to_kml" (geo objects)
Exports as KML 2.0.
o "serialialise_model(as => $format)" (all microformat objects)
Exports as RDF, serialised as $format. (Format can be 'RDFXML', 'Turtle', 'NTriples', 'RDFJSON'.)
Stuff that's b0rked
The "get_foo", "set_foo", "add_foo", "clear_foo" methods defined in HTML::Microformats::Format work unreliably and are poorly documented.
You're better off using the "data" method and inspecting the returned structure for the data you need. This will be fixed in the future.
Here be monsters
There are several parts of the code which are incredibly complicated and desperately need refactoring. This will be done at some point, so
don't rely too much on their current behaviour.
"stringify" and "_stringify_helper" in HTML::Microformats::Utilities. The whole of HTML::Microformats::Mixin::Parser.
SEE ALSO
HTML::Microformats.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT
Copyright 2008-2011 Toby Inkster
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2011-12-06 HTML::Microformats::Documentation::Notes(3pm)