- Strength to Increase Rep
- +7
- Strength to Decrease Rep
- -1
- Upvotes Received
- 22
- Posts with Upvotes
- 21
- Upvoting Members
- 7
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
SAMPLE TABLE 1 =================================== product Division sales % =================================== product1 divsion1 99 product2 divsion1 51 product3 divsion1 50 product4 divsion2 98 product5 divsion2 41 product6 divsion2 40 product7 divsion3 97 product8 divsion3 31 product9 divsion3 30 =================================== Expected output 1 =================================== product2 divsion1 51 product3 divsion1 50 product5 divsion2 41 … | |
Hi All, I have a sql query i am trying to get the count of how rows it returned. select a.field1, b.field2, c.field2 from table1 as a, table2 as b, table2 as c where a.field1=b.field1 Considered the above query return 9 rows. I want to get count of '9' in … | |
Hi, I am trying to get same field name from different tables. And i am using like the below query to get the field name. I am expecting some other queries to get distinct 'function_name' column from 'N' of tables. SELECT function_name FROM base_table UNION SELECT function_name FROM firstcall_table UNION … | |
Hi All, I am trying to write perl code for extract 'C' user defined function from 'diff' format file. I am using the below keyword to identify the function 'starting pharse' (return value). I am not familar about 'C'. Please suggest some addtion return type which missing from the below … | |
Hi all, I am not able to get correct count, if col1 (percentage with respect to product) and col2 have uniq value. Below I post my sample table data and expect output and which i query I tried. Please help me to get in to right direction. CREATE TABLE mysample … | |
Hi all, Below is my sample data. I am trying to get the 'product' name only if the percentage count is varying. Could you please suggest your maximum no of 'Mysql' queries to approach this. Thanks in advance. Input: ============================================== percentage product ============================================== 100.00 A 100.00 A 100.00 A 2.18 … | |
Hi All, I want to copy the missing 'data' field from 'tb1' to 'tb2' based on the 'id' value. Please suggest the possible queries. mysql> select * from tb1; +------+------+ | id | data | +------+------+ | 1 | A | | 2 | B | | 3 | C … | |
Re: [QUOTE=;][/QUOTE] [CODE] $string="4+21:00"; if ($string=~ m{(\d\+)?(\d\d)(\:)(\d\d)}){ print "\nMatched : $&"; } else { print "\nNot Matched"; } [/CODE] | |
Re: [QUOTE=;][/QUOTE] Instead of the line [icode]my $rec = join(',', @fields);[/icode] this adds the double quotes in the data [icode]my $rec = join ( ',', map ("\"$_\"", @fields));[/icode] | |
| Re: [QUOTE=;][/QUOTE] I assumed your excel file having only one sheet and the data will be two columns. The first column is the name field and second one is mail ids. Try the below code. [CODE] use strict; use Spreadsheet::ParseExcel; my $oExcel = new Spreadsheet::ParseExcel; die "You must provide a filename … |
Re: [QUOTE=;][/QUOTE] [CODE] File::Path File::Find File::Copy File::Basename [/CODE] The modules will be help to complete the needs. | |
Re: [QUOTE=;][/QUOTE] use the 'localtime' function and get the date format. [CODE] $filename='data.txt'; my ($sec,$min,$hour,$mday,$mon,$year)=localtime(); $year+=1900; $mon=sprintf("%02d", $mon+1); $mday=sprintf("%02d", $mday); my $today_file = "$year$mon$mday"."$filename"; print $today_file; [/CODE] Read More... [CODE] perldoc -f localtime [/CODE] | |
Re: The regex engines may reduce the process time, Instead of use the 'substr' inside of the 'for' loop for this case. [CODE] #!/usr/bin/perl use strict; use warnings; my $name='GTGAGCCAGAACTCATCTTCTTTGCTCGAAACCTGGCGCCAAGTTGTTGCCGATCTC'; my $num='50'; while($name=~ m{.{$num}}g) { print "\n\nFirst $num characters\t: $&"; my $reverse = reverse ($&); print "\nReverse $num characters\t: $reverse"; # … | |
Re: And another one way by using of expression statement [CODE] #!/usr/bin/perl; use strict; use warnings; while (<DATA>){ s/(\s+)/" [".length($1)." Spaces] "/ge; print ; } __DATA__ I wake up in the morning What time? Always wakeup at 6am.[/CODE] | |
Re: [CODE] use strict; use warnings; open (FIN, "test.xml") or die "Error : $!"; read FIN, my $file, -s FIN; close (FIN); my @table=(); # Get the necessary contents while ($file=~ m{<table((?:(?!<\/?table).)*)</table>}sg) { my $find=quotemeta($&); $file=~ s{$find}{}s; unshift(@table, $&); } # show the extracted conents for (my $i=0; $i<=$#table; $i++) { … | |
Re: [QUOTE=;][/QUOTE] 'map' process each element of an array. Here you no need use the map function. You directly add the @A elements to @aFN. [CODE] # map{push(@aFN,$_)}@A; push @aFN, @A; [/CODE] | |
Re: [iCODE]my $today = "$mon-$mday-$year";[/iCODE], Here $today holds the string values only. But you are using ( [iCODE]if($getdate == $today), if($date_flag == 'true')[/iCODE] ) numerical comparision opertor. When you want to compare two string use the 'eq' operator. | |
Re: [QUOTE=;][/QUOTE] [CODE] do { unlink if ( !/20110225104849|20110225104833|20110225104848/ ) } for @your_files; [/CODE] | |
Re: [QUOTE=;][/QUOTE] [CODE] ## Code block 1 my $filename = 'test.hrh'; #So you can use diamond operator and inplace editing push @ARGV, $filename; [/CODE] Here $fliename add into defalut array (@ARGV). [CODE] inline_replace.pl test.hrh [/CODE] Here the file name directly assigned to @ARGV. you want to pass the file name in … | |
Re: [QUOTE=;][/QUOTE] [CODE] $string = '(232,45,3434,535.56)'; $string =~ s/\( # match '(' character ( # start group1 [\d\.,]+ # match digit, dot, comma '1 to many' times ) # end group 1 \) # match ')' character /-$1/x; # retain the group1 # 'x' modifier Allows the white space for # … | |
I derived Datatable in one class(DataTableEx), then i created one property(TotalRecordCount), then i assigned 5000 to that new property(TotalRecordCount), then i convert this datatable into xml, so it's created.Now i try to convert xml to Datatable, i am not able to get 5000 value to TotalRecordCount Property. so how i … | |
Re: [QUOTE=;][/QUOTE] [CODE] my $pattern = "(g$)"; [/CODE] Here '$)' is perl special variable gives the effective group id of the process. So finally $pattern gets '(g0'. It's not a parsed regular expression. I assumed your try to match the letter 'g' at end of the line. So modify the below … | |
Re: [QUOTE=;][/QUOTE] $0 -> Gives the perl file name. @ARGV -> Holds the arguments values. use the above variable in your code and write the log file [CODE] print "\nCommand Line Option used : $0 @ARGV"; [/CODE] | |
Re: [QUOTE=;][/QUOTE] [CODE] use strict; use warnings; open (FIN, "time.txt")|| die "Cannot Open the input file : $!"; read FIN, my $file, -s FIN; close (FIN); $file=~s/(\d+)-(\d+)-(\d+)/$1*3600 + $2*60 + $3/ge; open (FOUT, ">Out_time.txt") || die "Cannot create the output file : $!"; print FOUT $file; close (FOUT); [/CODE] | |
Re: [QUOTE=;][/QUOTE] [CODE] perl -ne 'BEGIN{%email=qw(sam@email.com 1 john@email.com 1 jenifer@email.com 1 );} /Zip_Name:\s*(.*)/; $email{$1}=1; END{print "$_:$email{$_}\n" for sort keys %email;} ' input_file [/CODE] Note : The above code tested at linux. | |
Re: [QUOTE] mismatched tag at line 16, column 2, byte 228 at :/APPS/actperl/site/lib/XML/Parser.pm line 168 [/QUOTE] That is not valid xml format what you post. Goto 16 th line for and change 'ramputan' to 'rambutan'. Here I add the code, that affect the changes in the xml file. ( Thanks d5e5 … | |
Re: [QUOTE=;][/QUOTE] Please explain your input and the function returned or expected output... | |
Re: [QUOTE=;][/QUOTE] Anther One Way using Regex [CODE] use strict; use warnings; ### Read & store the whole file in $filea open (FILEA, "a.txt") || die "Cannot open the file a.txt : $!"; read FILEA, my $filea, -s FILEA; close (FILEA); ### Read the file B open (FILEB, "b.txt") || die … | |
Re: [QUOTE=;][/QUOTE] Here I added the code for read the .txt format files only. And the remaining things are same. [CODE] use strict; use warnings; my %hash; # Declare your directory my $dir='e:/dani/csv/fruit'; # read the txt file in the $dir opendir(DIR, $dir) || die "Cannot open the $dir : $!"; … | |
Re: [CODE] open (FIN, "test.csv") || die "Cannot Open the input file"; @file=<FIN>; close (FIN); ## CSV files are separated by comma ## So, split the data by using of 'comma' @get=split/,/, $file[1]; print "\nSecond word from second line : ", $get[1]; [/CODE] |