Hey all, I am teaching myself some simple CSV file manipulation and have become a little stuck. Say I have the following layout in the CSV file:
Is it possible to INSERT data into the CSV into the correct age order. For example, if I had the following data:
It would go in the CSV file in age order as follows (youngest to oldest):
I have a problem in that I don't have access to the useful Text::CSV library, so any solutions that do not involve an import would be a massive bonus (it doesn't matter if it's sloppy/inefficient as it's purely for educational purposes)
Thanks for your time.
---------- Post updated at 07:19 PM ---------- Previous update was at 04:17 PM ----------
Ok, so I've given up hope that it's possible to do what I want. Instead, I'm just going to sort the details on the fly; I'm still having some problems though. I've pieced together this sorting algorithm but it's only printing out memory locations (E.g: ARRAY(0x6a33e10))
Hi There
I have this file that I would like to add entries to, however, there is a "}" as the last line that I need to keep. Basically i would like to know how I can write a script that will add new lines at the second to last line position (ie always add new line above the close bracket)
... (17 Replies)
i have a file that looks like this:
000000112/01/2008 D99999
000000 12/01/2008 D99999
000000 12/01/2008 1D99999
i need to replace the blanks into 1 for column 7,18-19
how can this be achieved using awk?
Thanks. (1 Reply)
Hi,
I need to insert two new lines in a file:
The file:
".....
......
ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
....
....
"
I need to add the lines:
LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$APACHE_HOME/modules'
DOWNLOADMODULE_CONF_PATHNAME='$APACHE_HOME/conf/DWLModule.cfg'
right... (2 Replies)
Hi,
I am having trouble converting a text file. I have been working for this whole day now, still i couldn't make it.
Here is how the text file looks:
_______________________________________________________
DEVICE STATUS INFORMATION FOR LOCATION 1:
OPER STATES: Disabled E:Enabled ... (5 Replies)
Hi,
I have a to modify a line and insert a keyword in the middle to a specific location.
My line looks like this
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS (ABC, DEF, GHI)
I want to change it as
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING... (4 Replies)
Hello all
i know it is pretty hard one but you will manage it all
after noticing and calculating i find a rhythm for the file i want to edit
to copy the last 12 characters in line but the problem is to add after first 25 characters in same line
in other way too copy the last 12 characters... (10 Replies)
So I work in a 1 to 1 laptop deployment and sometimes we need to mass order parts. The vendor will send us a text file and we have to manually input serial numbers. Well I have a full blown web based inventory system which I can pull serial number reports from.
I then have to input the part... (4 Replies)
Hi,
Well my title isn't very clear I think. So to understand my goal:
I have a script "test1"
#!/bin/bash
xvkbd -text blabla
with xbindkeys, I bind F5 key in order it runs my test1 script
So when I press F5, test1 runs.
I'm under Emacs/Vi and I press F5 in order to have "blabla" be... (0 Replies)
Hi,
I have a file with some info as example below. Its a csv file and i want to interchange the location of the times and dates in the 3rd and 4th fields only. I am using SunOS and csh script and would like to incorporate sed or nawk in the script (or any that would be able to accomplish this).... (5 Replies)
Hi All,
I am trying to write a shell script where it should insert character 'I' in 180th position of each line(except first and last line) of the file. Below is the script
for file in /home/test/bharat/*.RET
do
# Process file
echo "File Name=" $file
#l_fileName="${file##*/}"
... (19 Replies)
Discussion started by: bharath561989
19 Replies
LEARN ABOUT DEBIAN
tm::serializable::csv
TM::Serializable::CSV(3pm) User Contributed Perl Documentation TM::Serializable::CSV(3pm)NAME
TM::Serializable::CSV - Topic Maps, trait for parsing (and later dumping) CSV stream
SYNOPSIS
# 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;
DESCRIPTION
This trait provides parsing and dumping from CSV formatted text streams.
INTERFACE
Methods
deserialize
$tm->deserialize ($text)
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):
o If the header line contains a field called "association-type", then all rows will be interpreted as assertions. In that the
remaining header fields (in that order) are interpreted as roles (role types). For all rows in the CSV stream, the position where
the "association-type" field was is ignored. The other fields (in that order) are affiliated with the corresponding roles.
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.
o If the header line contains a field called "id", then all further rows will be interpreted as topic characteristics, with each
topic on one line. The column position where the "id" field in the header is will be interpreted as toplet identifier.
All further columns will be interpreted according to the following:
o If the header column is named "name", the values will be used as topic names.
o Otherwise if the value looks like a URI, an occurrence with that URI value will be be added to the topic.
o Otherwise an occurrence with a string value will be added to the topic.
Example:
name,id,location,homepage
"Rumsti",rumsti,gold-coast,http://rumsti.com
"Ramsti",ramsti,vienna,http://ramsti.com
serialize
$tm->serialize
[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).
"header_line" (only for serialization)
This string contains a comma separated list (CSV parseable) of headings. If one of the headings is "association-type", then the
generated CSV content will contain associations only. Nothing else is implemented yet. The other headings control which roles (and
in which order) should be included in the CSV content. If a particular role type has more than one player, then all players are
included.
NOTE: As this is inconsistent, this will have to change.
"type" (only for serialization)
If existing, then this controls which association type is to be taken.
"baseuri" (only for serialization)
If existing and non-zero, the base URI of the map will remain in the identifiers. Otherwise it will be removed.
"specification"
If existing (and when selecting only associations), this specification will be interpreted in the sense of "asserts" (see TM).
Example:
$tm->serialize (header_line => 'association-type,location,bio-unit',
type => 'is-born',
baseuri => 0);
SEE ALSO
TM, TM::Serializable
AUTHOR INFORMATION
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
perl v5.10.1 2012-06-05 TM::Serializable::CSV(3pm)