There's a pretty detailed analysis of this problem in Friedl's book. It's somewhat more involved that Vijay's solution if you want to cover all the possible quirks of real-life CSV format. Here's one of the simpler approaches (from the first edition, sorry).
You could do the same in sed or awk, although Perl makes some parts of it easier.
I have a comma delimited file that sometimes has addresses details in. The problem is that the address detail can be seen as:
"Sample House, Sample Road". When I run a script specifying the file is comma delimited I would like it to ignore comma's that are in between speech marks.
Is this... (2 Replies)
I need to delete a set of files in certain directories if there're older than a certain number of days. So I have a text file, with each line containing the directory & number of days.
The format is like this:
dirA,5
dirB,7
How do I write script to iteratively parse this text file & delete... (5 Replies)
Hi All,
I have output of sql saved in comma separated file.
Now i need to read line by line this file
and assign word to a unix variable for further processing
Eg:
Test file
world, 1, 3, 4
earth,2,3,4,5
moon,1,2,3,4
Output should be
word1= world
word2=1
echo " first word... (7 Replies)
Hello,
I need to read a csv file and I am trying to replace a comma with a text DSEE?DSEE.
Example
Input
"Chapter","NewTrains, "oldTrains","Delayed",10,"London"
"Chapter","Newbuses,oldbuses","On Time",20,"London"
Output
"Chapter","NewTrainsDSEE?DSEE... (5 Replies)
I have a flat file whose contents are comma delimited and there are 84 columns in total, so everytime I try to view the contents, things get over lapped it becomes diffcult to read through the result set.
Is there a command / what would be the best way...if I want to view the results alligned... (4 Replies)
Question about how to change the first & last name in column one & two so that the names have a capital letter for just the first letter. Example:
asdf@asdf.com,asdf,asdfasdf,176.23.22.345,4/12/2012
changed to:
asdf@asdf.com,Asdf,Asdfasdf,176.23.22.345,4/12/2012
Thank you kindly,
Nick (2 Replies)
Hi All,
I need a unix script to convert .csv files to .skv files (changing a comma delimited file to a semi colon delimited file). I am a unix newbie and so don't know where to start. The script will be scheduled using cron and needs to convert each .csv file in a particular folder to a .skv... (4 Replies)
Hi,
I am wanting to create a script that will construct a SQL statement based on a a space delimited string that it read from a config file.
Example of the SQL will be
For example, it will read a string like "AAA BBB CCC" and assign to a variable named IN_STRING.
I then concatenate... (2 Replies)
Hi Experts,
Please support
I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6.
... (3 Replies)
Discussion started by: as7951
3 Replies
LEARN ABOUT DEBIAN
parse::debian::packages
Parse::Debian::Packages(3pm) User Contributed Perl Documentation Parse::Debian::Packages(3pm)NAME
Parse::Debian::Packages - parse the data from a debian Packages.gz
SYNOPSIS
use YAML;
use IO::File;
use Parse::Debian::Packages;
my $fh = IO::File->new("Packages");
my $parser = Parse::Debian::Packages->new( $fh );
while (my %package = $parser->next) {
print Dump \%package;
}
DESCRIPTION
This module parses the Packages files used by the debian package management tools.
It presents itself as an iterator. Each call of the ->next method will return the next package found in the file.
For laziness, we take a filehandle in to the constructor. Please open the file for us.
METHODS
new( $filehandle )
next
Iterate to the next package in the file, returns either a hash containing a package description, or false at end of file.
as_hash( $filehandle )
Return all the packages from a filehandle as a hash of hashes.
AUTHOR
Richard Clamp <richardc@unixbeard.net> with as_hash implementation by Thomas Klausner.
COPYRIGHT
Copyright (C) 2003,2005,2012 Richard Clamp. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Module::Packaged
perl v5.14.2 2012-03-11 Parse::Debian::Packages(3pm)