03-01-2012
Thanks Corona it works!!!
I want to make my program foolproof so I want to consider scenarios where data might not be in good format always...Please advise on how to handle below scenarios...
1. what if the name of the table or view is on the second line
create table
table1 (c1 integer)
2. What if there are multiple spaces between create, table and tablename
create table table1
I have taken care of the key words being in mixed case by using toupper function.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello All,
I have a file whose data looks something like this
I want to extract just the id, name and city fields in a csv format and sort them by id. Output should look like this.
1,psi,zzz
2,beta,pqr
3,theta,xyz
4,alpha,abc
5,gamma,jkl (12 Replies)
Discussion started by: grajp002
12 Replies
2. Shell Programming and Scripting
Hello fourm members,
I want to write a script to extarct paticular strings from the all type of files(.sh files,logfiles,txtfiles) and redirect into a log file.
example:
I have to find the line below in the script and extract the uname and Pwds.
sqsh -scia2007 -DD0011uw01 -uciadev... (5 Replies)
Discussion started by: rajkumar_g
5 Replies
3. Shell Programming and Scripting
input file
Desired csv output
gc_type, date/time, milli secs
af, Mar 17 13:09:04 2011, 144.596
af, Mar 20 00:37:37 2011, 144.242
af, ar 20 21:30:59 2011, 108.518
Hi All,
Any help in acheiving the above would be appreciated. I would like to parse through lines within one file and... (5 Replies)
Discussion started by: satish.vampire
5 Replies
4. Shell Programming and Scripting
Hi all,
Please go through my requirement.
I have a log file in the location /opt/WebSphere61/AppServer/profiles/EMQbatchprofile/logs/EMQbatch
This file contains the follwing pattern data
<af type="tenured" id="42" timestamp="May 14 13:44:13 2011" intervalms="955.624">
<minimum... (8 Replies)
Discussion started by: satish.vampire
8 Replies
5. Shell Programming and Scripting
Good afternoon!
I have an XML file from which I want to extract only certain elements contained within each line. The problem is that the format of each line is not exactly the same (though similiar). For example, oa_var will be in each line, however, there may be no value or other... (3 Replies)
Discussion started by: bab@faa
3 Replies
6. Shell Programming and Scripting
Hello guys,
I'm trying to extract all the expressions between the following tags: <b></b> from a HTML file.
This is how it looks: big lines containing several dozens expressions (made of 1,2,3,4,6 or even 7 words) I would like to extract:
<b>bla ble</b>bla ble</td><tr valign="top"><td... (3 Replies)
Discussion started by: bobylapointe
3 Replies
7. Shell Programming and Scripting
I have a file with
<suit:run date="Trump Tue 06/19/2012 11:41 AM EDT" machine="garg-ln" build="19921" level="beta" release="6.1.5" os="Linux">
Need to find word "build" then
extract build number, which is 19921 also
release number, which is 6.1.5 then
concatenate them to one variable as... (6 Replies)
Discussion started by: garg
6 Replies
8. Shell Programming and Scripting
I have the following lines in a log file. It would be great if some one can help me to create a new file with the just entries in the below format.
66.150.161.195 HPSAC=Z05
66.150.161.196 HPSAC=A05
That is just extract the IP address and the string DPSAC=its value
66.150.161.195 -... (1 Reply)
Discussion started by: Tuxidow
1 Replies
9. UNIX for Dummies Questions & Answers
Dear all,
I have a data like below (n of rows=400,000) and I want to extract the rows with certain strings. I use code below. It works if there is not too many strings for example n of strings <5000. while I have 90,000 strings to extract. If I use the egrep code below, I will get error:
... (3 Replies)
Discussion started by: forevertl
3 Replies
10. UNIX for Beginners Questions & Answers
I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file.
I would like to output the lines of File2 which... (1 Reply)
Discussion started by: jvoot
1 Replies
LEARN ABOUT DEBIAN
anydata::format::htmltable
AnyData::Format::HTMLtable(3pm) User Contributed Perl Documentation AnyData::Format::HTMLtable(3pm)
NAME
HTMLtable - tied hash and DBI/SQL access to HTML tables
SYNOPSIS
use AnyData;
my $table = adHash( 'HTMLtable', $filename );
while (my $row = each %$table) {
print $row->{name},"
" if $row->{country} =~ /us|mx|ca/;
}
# ... other tied hash operations
OR
use DBI
my $dbh = DBI->connect('dbi:AnyData:');
$dbh->func('table1','HTMLtable', $filename,'ad_catalog');
my $hits = $dbh->selectall_arrayref( qq{
SELECT name FROM table1 WHERE country = 'us'
});
# ... other DBI/SQL operations
DESCRIPTION
This module allows one to treat the data contained in an HTML table as a tied hash (using AnyData.pm) or as a DBI/SQL accessible database
(using DBD::AnyData.pm). Both the tiedhash and DBI interfaces allow one to read, modify, and create HTML tables from perl data or from
local or remote files.
The module requires that CGI, HTML::Parser and HTML::TableExtract are installed.
When reading the HTML table, this module is essentially just a pass through to Matt Sisk's excellent HTML::TableExtract module.
If no flags are specified in the adTie() or ad_catalog() calls, then TableExtract is called with depth=0 and count=0, in other words it
finds the first row of the first table and treats that as the column names for the entire table. If a flag for 'cols' (column names) is
specified in the adTie() or ad_catalog() calls, that list of column names is passed to TableExtract as a headers parameter. If the user
specifies flags for headers, depth, or count, those are passed directly to TableExtract.
When exporting to an HTMLtable, you may pass flags to specify properties
of the whole table (table_flags), the top row containing the column names
(top_row_flags), and the data rows (data_row_flags). These flags follow
the syntax of CGI.pm table constructors, e.g.:
print adExport( $table, 'HTMLtable', {
table_flags => {Border=>3,bgColor=>'blue'};
top_row_flags => {bgColor=>'red'};
data_row_flags => {valign='top'};
});
The table_flags will default to {Border=>1,bgColor=>'white'} if none
are specified.
The top_row_flags will default to {bgColor=>'#c0c0c0'} if none are
specified;
The data_row_flags will be empty if none are specified.
In other words, if no flags are specified the table will print out with
a border of 1, the column headings in gray, and the data rows in white.
CAUTION: This module will *not* preserve anything in the html file except
the selected table so if your file contains more than the selected table,
you will want to use adTie() or $dbh->func(...,'ad_import') to read the
table and then adExport() or $dbh->func(...,'ad_export') to write
the table to a different file. When using the HTMLtable format, this is the
only way to preserve changes to the data, the adTie() command will *not*
write to a file.
AUTHOR & COPYRIGHT
copyright 2000, Jeff Zucker <jeff@vpservices.com> all rights reserved
perl v5.10.1 2004-08-17 AnyData::Format::HTMLtable(3pm)