transform one2many table

2007-05-15 Thread Andrej Kastrin
Dear all, I want to transform one2many like table to one2one table. Original table looks as follows: 1|Michael 1|Alex 1|Bob 1|Pete 2|Bob 2|Andre 2|David 2|Alex 3|Pete and the output should be similar to; 1|Michael Alex Bob Pete 2|Bob Andre David Alex 3|Pete Table is large (4 GB), so I think t

Equal keys in hash

2007-06-02 Thread Andrej Kastrin
Deal all, if the key already exists in the hash, then its value is overwritten. So, if I have the following structure of the input file A foo A faa A hoo B foo B aaa C bbb what is the procedure of choice to store all key-value pairs into the hash and print it out? Thanks in advance for any

Count co-occurrences

2007-06-22 Thread Andrej Kastrin
Dear all, I wrote a simple sql querry to count co-occurrences between words but it performs very very slow on large datasets. So, it's time to do it with Perl. I need just a short tip to start out: which structure to use to count all possible occurrences between letters (e.g. A, B and C) under

Re: Count co-occurrences

2007-06-22 Thread Andrej Kastrin
Paul Lalli wrote: On Jun 22, 12:48 pm, [EMAIL PROTECTED] (Andrej Kastrin) wrote: I wrote a simple sql querry to count co-occurrences between words but it performs very very slow on large datasets. So, it's time to do it with Perl. I need just a short tip to start out: which structure t

DBI, postgresql and large table

2007-06-27 Thread Andrej Kastrin
Dear all, I need to process postgresql table with DBI module. The script below works well for small tables, but when I want to process larger tables (10 rows) out-of-memory occurs. Any suggestion? Thanks in advance, Andrej use strict; use warnings; use DBI; my $dbh = DBI->connect("DBI:P

Re: DBI, postgresql and large table

2007-06-27 Thread Andrej Kastrin
Chas Owens wrote: On 6/27/07, Andrej Kastrin <[EMAIL PROTECTED]> wrote: Dear all, I need to process postgresql table with DBI module. The script below works well for small tables, but when I want to process larger tables (10 rows) out-of-memory occurs. Any suggestion? Thanks in a

Net::Amazon question

2007-09-02 Thread Andrej Kastrin
Dear all, script below use Net::Amazon module to parse similar items (Customer who bought this also bought...) from Amazon. But there are only 10 item displayed in the result set. I try with Net::Amazon 0.35 and 0.43 respectively, but the result is always the same. What's wrong with my code? Than

Last line issue

2008-01-26 Thread Andrej Kastrin
Dear all, to pre-process my XML dataset in run simple Perl script on it, which extract Id identifier from XML data and paste the whole XML record to it. For example, the input data looks like: 001 Thomas Joana 002 John Paula

Re: Last line issue

2008-01-26 Thread Andrej Kastrin
with the output: 001 001ThomasJoanafoo 002 002JohnPaulafoo 003 003AndrewMariafoo Note that there is no opening tag at the beginning. Best, Andrej John W. Krahn wrote: Andrej Kastrin wrote: Dear all, Hello, to pre-process my XML dataset in run simple Perl script on it, which extract Id

Which structure to handle data

2006-04-03 Thread Andrej Kastrin
Dear Perl community, I need to re-sort a set of data. I think that the below example is self explained; so which Perl structure should I use to handle this dataset? Thanks in advance for any suggestion, Andre 2;John;Apple;Banana 3;Andrew;Pear;Apple;Melon;Orange 8;Susan;Pear;Melon 2;John;App

Sum problem

2006-05-29 Thread Andrej Kastrin
Dear Perl users, I have 2 columns, tab separated file which looks like A 4 B 3 C 1 A 3 B 3 First column refers to name and second to value. I have to calculate total score on each 'name'; in my case: A 7 B 6 C 1 Here is the code; but it doesn't work. # whi

hash and array question

2006-05-31 Thread Andrej Kastrin
Dear Perl users, below is three column, vertical bar separated file. First column refers to ID number, second designates name and the last one refers to corresponding value. There are 8 possible names: A, B, C, D, E, F, G and H (only first seven preset in my dataset) 1 | C | 0.404 1 | D | 0.

Parse XMP file -- foreach problem

2006-07-03 Thread Andrej Kastrin
Dear Perl community I have to parse ID, TITLE and SYMBOL fields from the file below. In this manner I wrote (modify actually) simple script to do that for me. 001 FIRST TITLE SYMBOL AAA SECOND CCC 002 SECOND TITLE SYMBOL HHH Script below work well, if there is

Intersection for each pair of arrays

2006-08-23 Thread Andrej Kastrin
Hi, below is simple solution for union and intersection for a pair of arrays (@a and @b). How to modify this example that I can calculate union and intersection for each pair of "n" arrays. Thanks in advance for any suggestion, Andrej ## use warnings; @a = (1, 3, 5, 6, 7

Your opinion on large file processing

2006-09-23 Thread Andrej Kastrin
Dear all, the script below count word occurences in input file. It uses simple hash structure to store unique words and its frequencies. use strict; my %words; while (<>) { chop; foreach my $wd (split) { $words{$wd}++; } } foreach my $w (

Re: Your opinion on large file processing

2006-09-25 Thread Andrej Kastrin
Peter Scott wrote: On Sat, 23 Sep 2006 11:51:54 +0200, Andrej Kastrin wrote: the script below count word occurences in input file. It uses simple hash structure to store unique words and its frequencies. [...] foreach my $w (keys %words) { print "$w|$words{

Maximum value in Hash

2006-10-02 Thread Andrej Kastrin
Dear all, I'm looking for simple (and fast) solution to extract maximum value from a hash. I search over the Perl mailing lists, but I didn't find anything usable. Thanks in advance for any suggestion, Andrej -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAI

Re: Maximum value in Hash

2006-10-02 Thread Andrej Kastrin
John W. Krahn wrote: Andrej Kastrin wrote: Dear all, Hello, I'm looking for simple (and fast) solution to extract maximum value from a hash. I search over the Perl mailing lists, but I didn't find anything usable. One way to do it: my $max; $max < $_ and

How to sum up values

2007-04-24 Thread Andrej Kastrin
Dear all, Question about the sum function; the file structure is as follows: A|100 A|200 A|150 B|20 B|90 C|10 C|30 C|300 The result I want to obtain is to sum values in the second column (columnB) for each particular letter in the first column (ColumnA); e.g.: A|450 B|100 C|330 I don't want

From column to row?

2005-11-28 Thread Andrej Kastrin
Hi, I am totally NOOB in Perl and here is my first problem, which I couldn't solve... I have column data in file xy.txt, which looks like: A B C ABCDD .. . Now I have to transform this to row data file in the following way: "A","B","C","ABCDD" Is that possible? Thanks i

Re: From column to row?

2005-11-28 Thread Andrej Kastrin
Chris Devers wrote: On Mon, 28 Nov 2005, Andrej Kastrin wrote: Hi, I am totally NOOB in Perl and here is my first problem, which I couldn't solve... I have column data in file xy.txt, which looks like: A B C ABCDD .. . Now I have to transform this to row data file i

Open source IDE for Perl

2005-11-30 Thread Andrej Kastrin
Dear all, which is yours "best" open source IDE for Perl. I use SciTE under Linux, but I'm a little confused on Windows. Which do you prefer? Best, Andrej -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Open source IDE for Perl

2005-11-30 Thread Andrej Kastrin
Octavian Rasnita wrote: From: "Andrej Kastrin" <[EMAIL PROTECTED]> Dear all, which is yours "best" open source IDE for Perl. I use SciTE under Linux, but I'm a little confused on Windows. Which do you prefer? Best, Andrej I use TextPad. Te

Extract text from file

2005-12-07 Thread Andrej Kastrin
Hello dears, I have a file in row data format, which stores different terms (e.g. genes) and look like: ABH HD HDD etc. Then I have second file which looks like: -- ID- 001 #ID number TI- analysis of HD pa

Re: Extract text from file

2005-12-07 Thread Andrej Kastrin
Shawn Corey wrote: Andrej Kastrin wrote: Hello dears, I have a file in row data format, which stores different terms (e.g. genes) and look like: ABH HD HDD etc. Then I have second file which looks like

Re: Extract text from file

2005-12-07 Thread Andrej Kastrin
Chris Charley wrote: - Original Message - From: "Andrej Kastrin" <[EMAIL PROTECTED]> Newsgroups: perl.beginners To: "Perl Beginners List" Sent: Wednesday, December 07, 2005 12:00 PM Subject: Extract text from file Hello dears, I have a file in row

Run *.pl file from Emacs

2005-12-09 Thread Andrej Kastrin
Hi all, I already know how to compile perl script (M-x compile) in Emacs, but is there any solution to run it too. Cheers, Andrej -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Input separator and block problem

2005-12-11 Thread Andrej Kastrin
Hi I want to count words in the following file: -- ID- some number TI- some text BB AB- some text AU- some text ID- some number TI- some GGG text AB- some text AU- some text ID- some number TI- some text AB- some text Z AU- some text -- So

Re: Input separator and block problem

2005-12-12 Thread Andrej Kastrin
Andrej Kastrin wrote: Hi I want to count words in the following file: -- ID- some number TI- some text BB AB- some text AU- some text ID- some number TI- some GGG text AB- some text AU- some text ID- some number TI- some text AB- some text Z AU- some text

Problem with foreach

2005-12-12 Thread Andrej Kastrin
Hello dears, I want to count words in the following file: -- ID- some number TI- some text BB AB- some text A BB AU- some text ID- some number TI- some GGG text AB- some text GGG AU- some text ID- some number TI- some text AB- some text Z AU- some text --

Re: Problem with foreach

2005-12-12 Thread Andrej Kastrin
John W. Krahn wrote: Andrej Kastrin wrote: Hello dears, Hello, I want to count words in the following file: -- ID- some number TI- some text BB AB- some text A BB AU- some text ID- some number TI- some GGG text AB- some text GGG AU- some text ID

Problem with regular expression

2005-12-14 Thread Andrej Kastrin
Hi all I have a list of terms and I have to find out, if any one of them occur in my text. Example: term is e.g. ABCB1 wich is store in variable $w and my regular expression is "...if /^TI.*?\s$w\s/m..." .That way I successfully found ABCB1, but if the therm is parenthesize (e.g. (ABCB1)) t

Equal length numbers

2005-12-15 Thread Andrej Kastrin
Hi all, Suppose that we have numbers 1 to 1000 and we want all numbers be equal length; e.g.: 0001 0002 0003 ... .. 1000 Any idea on how to fix this problem? Best, Andrej -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Equal length ID numbers

2005-12-15 Thread Andrej Kastrin
Hi all, Suppose that we have numbers 1 to 1000 and we want all numbers be equal lengh; e.g.: 0001 0002 0003 ... .. 1000 Any ideaa on how to fix this problem? Best, Andrej -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Split element in array

2005-12-19 Thread Andrej Kastrin
Hi all So, I have 4 fields file; fields are tab separated: 1 BRCA3 BRCA33|BRCA55 symbol 998 2 ABCB1 DASH|BASG|AVGA4 symbol 7583 In first step I split each row and store it in array; e.g.: @array=( '1', 'BRCA3', 'BRCA33|BRCA55', 'symbol998') Now I have to split thir

Re: Split element in array

2005-12-19 Thread Andrej Kastrin
Ing. Branislav Gerzo wrote: Andrej Kastrin [AK], on Monday, December 19, 2005 at 10:41 (+0100) typed: AK> 1 BRCA3 BRCA33|BRCA55 symbol 998 AK> 2 ABCB1 DASH|BASG|AVGA4 symbol 7583 AK> In first step I split each row and store it in array; e.g.: AK> @array=( 

Distribution of words length

2005-12-23 Thread Andrej Kastrin
Hi, I'm totally confuse, while I haven't any idea how to solve my problem. I have "n" lines text with one word in each line and I have to make a frequency distribution of words length. If I have text: hfdjhgsj #length=8 abcabc #length=6 adr #length=3 bhvfgt #length=6 vvv #lengt=3 So, the outpu

read column into array

2005-12-27 Thread Andrej Kastrin
Hi all, is there any simple way to read a column of a file into array; e.g. read second column a b h e r z u e u and write it to @array=(b,r,e). Cheers, Andrej -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Combine multiple lines into one line

2006-01-16 Thread Andrej Kastrin
Hi all, I have the file, which looks like: *RECORD* *ID* 001 *TITLE* Here is title number one. *ABSTRACT* First sentence of the abstract. Second sentence of the abstract... Second line of the abstract. *RECORD* *ID* 002 *TITLE* Here is title number one. *ABSTRACT* First sentence of the abstract

Transform column into row

2006-01-18 Thread Andrej Kastrin
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 te

Re: Transform column into row

2006-01-18 Thread Andrej Kastrin
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 mul

Re: Transform column into row

2006-01-19 Thread Andrej Kastrin
Andrej Kastrin wrote: 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

Array problem

2006-01-22 Thread Andrej Kastrin
I wrote simple script, which have to concatenate multiple lines into array and then print each element of tihis array: open INPUT,"<$ARGV[0]"; while ($line=){ push (@array,$line); foreach $i(@array){ print $i; } } Input is e.g. line 1 line 2 I don't know where is the problem, Pl

Hash problem

2006-01-30 Thread Andrej Kastrin
Dear all, I have bar separated file: name1|345 name2|201 ... I store it into a hash; while () { chomp; ($name,$score) = split (/\|/,$_); $hash{$name} = $score; } Then I have second file: ID - 001 NA - name1 NA - name2 ID - 002 NA - name2 NA - name4 ... I match all ID's and NA's: while

Re: Hash problem

2006-01-30 Thread Andrej Kastrin
John Doe wrote: Andrej Kastrin am Montag, 30. Januar 2006 10.14: Dear all, I have bar separated file: name1|345 name2|201 ... I store it into a hash; while () { chomp; ($name,$score) = split (/\|/,$_); $hash{$name} = $score; } Let's assume the resulting hash is %s

Re: Hash problem

2006-01-31 Thread Andrej Kastrin
John W. Krahn wrote: Andrej Kastrin wrote: Dear all, Hello, I have bar separated file: name1|345 name2|201 ... I store it into a hash; while () { chomp; ($name,$score) = split (/\|/,$_); $hash{$name} = $score; } Then I have second file: ID - 001 NA - name1 NA - name2 ID

Hash problem

2006-02-15 Thread Andrej Kastrin
Dear Perl users, I have some problems wih the folowing algorithm: File A: - ID - 001 AD - Bill AD - Castro AD John ID - 002 AD - Andrew AD - Mike etc. - Then in the second file I have some values for each AD: - Andrew - 10 Bill - 20

Process large file with hash

2006-02-18 Thread Andrej Kastrin
Dear Perl users, I try to parse 20.000.000 records file but... To solve my recent Perl problem I collect my previous posts on this list. I have bar separated file (FILE_A): name1|10 name2|20 name3|5 name4|30 etc. I processed it with the following code: my %scores; while ( ) { chomp; m

User define switch

2006-02-20 Thread Andrej Kastrin
Dear all, Is there any simple way to add user defined switches in Perl. I want someting like that: perl --filein MyInputFileName --fileout MyOutputFileName ##in command line With --filein switch I want to define file, which will be read as the input and with the --fileout the output file.