Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Data_search

This is a perl script search engine which allows a search on a series of related files within a directory and returns matches in HTML table format. This effectively provides Ascii database functionality

News - Version 1.1 has been released which with one line allows specific fields to be selected

All scripts within this site are free -  mail us if you have any issues or suggestions about the scripts

Version 1.0

Version 1.1

Download

Download

View Example

View Example

   WAX - the web enabled contacts manager click here

About the examples, We have 2 csv files in our directory

Enter zipcode
or city for
forecast:
 

countries_america.csv

Canada,Ottawa,35

United States,Washington,255

Mexico,Mexico City,120

 

countries_europe.csv

France,Paris,55

United Kingdom,London,60

Italy,Rome,70

Germany,Berlin,80

Form using data _search_1 script

 

   

Modus Operandus

Notes - you should have all data files in an exclusive directory with the same data structure e.g. user1.csv user2.csv . Files will usually have been separated for security reasons where a user owns their own file. data_search will allow a super user to query all files in the directory.

1. We set the header within the script as follows

$myheader = "Country,Capital City,Population (M)";

2. We now run the query e.g. http://purpleflash.netfirms.com/cgi-bin/data_search.pl?searchword=paris  and all CSV files are searched for the word paris. The resultant matched record is displayed as  a HTML table . Note searchword=france would have given the same result.  Now if we use searchword=united it shows both the US and UK. This demonstrates that we are effectively viewing the files within the directory as a database.

3. Selecting fields Version 1.1. allows specific fields to be selected - These are set through $myfields = "0,1"; In this case http://purpleflash.netfirms.com/cgi-bin/data_search_1.pl?searchword=paris  will return the first two columns only - ie France,Paris i.e the first two fields (Note , fields are numbered from 0. 

4. FAQs 11)I have a series of csv files in a directory - Does data_search only work with files having three fields as per the above example.

1) No - you can have as many fields as you can view in a table. Ensure that your $myheader field definitions are consistent with the file field definitions.                             

2) Is there a limit to the number of files that data_search can access? 2)In short, no so long as they match the file type defined (e.g. csv, txt etc).

3) What developments do you have planned- 3) Incorporation of variable operators within the search facility

4) I don't know my base directory- 4) Your ISP should let you have it - On my Redhat linux  intranet the root base directory is /home/httpd/html( above version 6.2. this is /var/html/www/). If all fails run our script env_var.pl from your cgi-bin directory and look at the value mypath. Often you'll have to prefix this with /home.

5) Will data_search work on a single data file 5) Yes. If you like you can name the specific file e.g. $filetype = "address.csv"

6) You have used a comma as a separator - How do I use | 6) Change the following lines

$myheader = "header1|header2|header3|header4";

$myfields = "0|1|2|3";

@cdata = split(/\|/,$myheader);

@cfields = split(/\|/,$myfields);

@cdata = split(/\|/,$line);