in reply to Re^11: Text::CSV encoding parse()
in thread Text::CSV encoding parse()
Hi @haukex sorry I can't give you the whole script due to security and privacy concerns, but I can give you the salient parts of it.
#execute the query using Aginity Workbench; output saved to flat filfe my($res) = system($cmd); ### read the output my(@urls); my($header); open my $fh, "<:encoding(utf8)", "$resultsFile" || die("cannot open re +sults file $resultsFile for reading.\n cmd: $cmd"); my($c)=0; # just here for counting my($d)=0; # just here for counting while(<$fh>){ $c++; if($c == 1) { # get header row $header = $_; } if ($_ =~ /\/search\//){ push(@urls, $_); } else{ $d++; } } close($fh); # sort @urls based on the search string # e.g. https://www.ibm.com/support/knowledgecenter/es/search/¿Cuales s +on las partes de una cadena de conexión??scope=SSGU8G_12.1.0|https:// +www.ibm.com/support/knowledgecenter/es/SSGU8G_12.1.0/com.ibm.jdbc_pg. +doc/ids_jdbc_011.htm|0|1|1|0 my @sorted_urls = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { m|/search/\s*([^\?]+)\?|; [$_, $1] } @urls; # parse and print print $q->header(-charset => 'utf-8'); print $q->start_html( -title => 'SearchME', -style=>{'src'=>$stylesheet}); print $q->start_table(); foreach my $row (@sorted_urls){ # print TEMP $row; $csv->parse($row); print "<tr>"; $count++; my @els = $csv->fields; my(@splits) = split('\|',$row); $els[0] =~ /\/search\/(.+)\?scope=/i; my($term) = $1; my($link) = $els[0]; print "<td>"; # print $link; print $q->a({-href=>$link,-target=>'_blank'},$term); print "</td>"; # print other @fields here inside <td></td> } print $q->end_table, $q->end_html;
oh and I reinstalled both modules.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^13: Text::CSV encoding parse()
by haukex (Archbishop) on Aug 21, 2019 at 20:12 UTC | |
by slugger415 (Monk) on Aug 21, 2019 at 22:22 UTC | |
by hippo (Bishop) on Aug 22, 2019 at 08:49 UTC | |
by slugger415 (Monk) on Aug 22, 2019 at 18:25 UTC | |
by hippo (Bishop) on Aug 23, 2019 at 13:26 UTC | |
|
In Section
Seekers of Perl Wisdom