Help - Search - Member List - Calendar
Full Version: Matching records in columns
WorkTheWeb Forums > Webmaster Resources > Perl Beginner Help
Support our Sponsors!
Pablo Wolter
Hi,

I was searching how to do this but I have no idea if it is possible in perl.

I have data like this:

col1 col2 col3 col4
row1 a b
row2
row3 c

I need to extract only the name of the col (for example col3) and the
data that col has (b in this case) only if there is data. I don't have
to extract col4 row1, col2 row 2 for example.

Is this possible with Perl and wich book/guide/tutorial I should read to
learn to do this? Code will be welcome but I want to lear this technique
if it is possible.

Thanks in advance.

Pablo.

Chris Devers
On Fri, 24 Jun 2005, Pablo Wolter wrote:

QUOTE
I was searching how to do this but I have no idea if it is possible in
perl.

All things are possible :-)

Well okay maybe not *all*, but if you can describe in detail what you
want to do, you can, in general, find a way to make it work in almost
any language, including Perl. The trick is the "in detail" part...

QUOTE
I have data like this:

How is your data, exactly? Is this the contents of a database table? Is
it in a CSV text file, or just raw ASCII text? Do you already have some
kind of two-way matrix in array of arrays? Something else?

There's a lot of ways that this problem, in the abstract, could be
solved, but the details will vary considerably depending on what the
starting data looks like. For starters, it would help to have a clearer
idea of what form the data is coming in as, and how it's being stored,
either in your program or externally (file, database, etc).

But in general, yeah, there are techniques for, essentially, getting the
X,Y coordinates of a grid element. It may be overkill, but if you're
looking for a book with such things, _Mastering Algorithms with Perl_
may not be a bad place to look.



--
Chris Devers

Pablo Wolter
Chris Devers wrote:

QUOTE
On Fri, 24 Jun 2005, Pablo Wolter wrote:



I was searching how to do this but I have no idea if it is possible in
perl.



All things are possible :-)

Well okay maybe not *all*, but if you can describe in detail what you
want to do, you can, in general, find a way to make it work in almost
any language, including Perl. The trick is the "in detail" part...



I have data like this:



How is your data, exactly? Is this the contents of a database table? Is
it in a CSV text file, or just raw ASCII text? Do you already have some
kind of two-way matrix in array of arrays? Something else?



My data comes from log files and the rows cols are different depending

in what users are selecting in our application. This "matriz" style data
comes with some lines in the top and some lines down that I'll be
interested too depending in the content of data (I know how to extract
and process this part). I'm a kind of lost with the "matrix" like data.

QUOTE
There's a lot of ways that this problem, in the abstract, could be
solved, but the details will vary considerably depending on what the
starting data looks like. For starters, it would help to have a clearer
idea of what form the data is coming in as, and how it's being stored,
either in your program or externally (file, database, etc).

But in general, yeah, there are techniques for, essentially, getting the
X,Y coordinates of a grid element. It may be overkill, but if you're
looking for a book with such things, _Mastering Algorithms with Perl_
may not be a bad place to look.




I'll take a look on that book. I already have Perl Cookbook and Learning

Perl and Programming Perl but I don't get it from there....or I need to
read more pages...could be.

Thanks for the help, as soon I get some code I'll show it to you

Pablo


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.