TM::Serializable::CSV
Topic Maps, trait for parsing (and later dumping) CSV stream
- Provided by: libtm-perl (Version: 1.56-10)
- Report a bug
Topic Maps, trait for parsing (and later dumping) CSV stream
# 1) bare bones my $tm = .....; # get a map from somewhere (can be empty) Class::Trait->apply ($tm, "TM::Serializable::CSV"); use Perl6::Slurp; $tm->deserialize (slurp 'myugly.csv'); # 2) exploiting the timed sync in/out mechanism my $tm = new TM::.... (url => 'file:myugly.csv'); # get a RESOURCEABLE map from somewhere $tm->sync_in;
This trait provides parsing and dumping from CSV formatted text streams.
This method consumes the text string passed in and interprets it as CSV formatted information. What topic map information is generated, depends on the header line (the first line):
Example:
association-type,location,bio-unit
is-born,gold-coast,rumsti
is-born,vienna,ramsti
Scoping cannot be controlled. Also all players and roles (obviously) are directly interpreted as identifiers. Subject identifiers and locators are not (yet) implemented.
All further columns will be interpreted according to the following:
Example:
name,id,location,homepage "Rumsti",rumsti,gold-coast,http://rumsti.com "Ramsti",ramsti,vienna,http://ramsti.com
[Since TM 1.53] This method serializes a fragment of a topic map into CSV. Which fragment can be controlled with the header line and options (see constructor).
NOTE: As this is inconsistent, this will have to change.
Example:
$tm->serialize (header_line => 'association-type,location,bio-unit',
type => 'is-born',
baseuri => 0);
TM, TM::Serializable
Copyright 2010 Robert Barta.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. http://www.perl.com/perl/misc/Artistic.html