Paul Johnson am Mittwoch, 18. Januar 2006 13.53: > On Wed, Jan 18, 2006 at 01:34:01PM +0100, John Doe wrote: > > Andrej Kastrin am Mittwoch, 18. Januar 2006 10.49: > > > Dear Perl users, > > > > > > what's the best way to transform column table in row format. I know > > > how to split each line according to delimiter and than put it > > > separately into array, but I have more complicated problem (with > > > multiple equal records in the first column) > > > > > > id001 text1 > > > id001 text2 > > > id001 text3 > > > id002 text23 > > > id002 text555 > > > id003 text666 > > > > > > and want something like: > > > > > > id001 text1 text2 text3 > > > id002 text23 text 555 > > > id003 text666 > > > > > > Thank's for any suggestions. > > > > My suggestion is that you show us what you tried so far, since this list > > is not a script service. > > But he didn't ask for a script, he asked for suggestions on the best way > to do something.
You are right. I apologize for that as well as for my tone. Partly it is due to my bad english, I miss the subtilities. > [As a side note, and not directed specifically to John Doe, this list > seems to be becoming a little less friendly to beginners than it used to > be. I think that is a shame. There are some people on the list, especially J.W. Krahn (and others), who are always very polite with any kind of questions :-) [...] > In most programming problems, I find that if you can design the correct > data structures the code pretty much writes itself. In this case, the > correct data structure seems to be a hash of arrays. See perldoc > perldsc. With this data structure, and the knowledge you already have, > I would expect a solution to present itself. If you still have > problems, do as John Doe suggests, and come back to us with the code you > have already tried. Another way (I don's say a better :-) ) could be not using a data structure, but doing the transformation on the fly: - read a line of the input data - record the first or a new field name while scanning (id001 etc.) - if the field name is new / has changed, output it to a new file - if it is not new / has not changed, append the value(s) - repeat these steps joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>