By using this site, you agree to our Privacy Policy and our Terms of Use. Close

Forums - General Discussion - Does anyone know web programming, CGI or PERL stuff I guess?

 

I have a static flat-file database that I need to use in a look-up function. The file looks like this:

380501-381000,160,06,1,11,500,1902
381001-381500,170,06,1,15,500,1902
381501-382500,330,18,1,15,1000,1902
382501-383000,160,06,1,11,500,1903
383001-383500,170,06,1,15,500,1903
383501-384000,302,18,1,15,500,1903
384001-384500,160,06,1,11,500,1903
384501-384900,291,16,1,17,400,1903
384901-385200,281,16,1,15,300,1903
385201-385500,291,16,1,17,300,1903

and it runs up to 1.3 million, all the same format. So all I want is a page with a input box and a search button. A person inputs a number in and the line that number is in is shown in a search result and some of the other information that is taken from the same text line. How long should something like that take to program? I used to code in XBase and a program like that would take about 45 minutes. Any thoughts? Does anyone know how to do this as a web application? 

 



Around the Network

I could do it as an HTML page with JS to look up values from the file. I could do it quickly with a form-based PHP file. I could do it with a Java-based server running on Tomcat and a servlet. The JS solution would take less than 45 minutes. PM me if you're interested.



explode function in php will work



I just need it to do something like this:

 

And the after the number is entered return the result:

 And the data looks like this:

380501-381000,160,06,1,11,500,1902
381001-381500,170,06,1,15,500,1902
381501-382500,330,18,1,15,1000,1902
382501-383000,160,06,1,11,500,1903
383001-383500,170,06,1,15,500,1903
383501-384000,302,18,1,15,500,1903
384001-384500,160,06,1,11,500,1903
384501-384900,291,16,1,17,400,1903
384901-385200,281,16,1,15,300,1903
385201-385500,291,16,1,17,300,1903

 



This shouldn't be too difficult in perl. You could create a hash with that identifier as the hash keys and the data as the values associated with the keys and then do a split. Loading 1.3 million lines like that from a flat text file would probably blow, though, especially if you had to do it over and over again. Since it's static, why dont you convert it into some sort of binary database file? SQLite would probably work really well here and would simplify the code to a series of SQL queries.



Around the Network
phil said:
This shouldn't be too difficult in perl. You could create a hash with that identifier as the hash keys and the data as the values associated with the keys and then do a split. Loading 1.3 million lines like that from a flat text file would probably blow, though, especially if you had to do it over and over again. Since it's static, why dont you convert it into some sort of binary database file? SQLite would probably work really well here and would simplify the code to a series of SQL queries.

 So you would make a hash table for every single possibility? That sounds very innefficient.



fkusumot said:
phil said:
This shouldn't be too difficult in perl. You could create a hash with that identifier as the hash keys and the data as the values associated with the keys and then do a split. Loading 1.3 million lines like that from a flat text file would probably blow, though, especially if you had to do it over and over again. Since it's static, why dont you convert it into some sort of binary database file? SQLite would probably work really well here and would simplify the code to a series of SQL queries.

So you would make a hash table for every single possibility? That sounds very innefficient.


It is inefficient. I guess you don't have to populate an entire hash/array(I may have misinterpreted how your data is present in the file), but your program is still going to be insanely inefficient because you're searching through 1.3 million records in a flat text file, so you probably wouldn't notice much difference unless the record you're looking for happens to be near the top of the file.

phil said:
fkusumot said:
phil said:
This shouldn't be too difficult in perl. You could create a hash with that identifier as the hash keys and the data as the values associated with the keys and then do a split. Loading 1.3 million lines like that from a flat text file would probably blow, though, especially if you had to do it over and over again. Since it's static, why dont you convert it into some sort of binary database file? SQLite would probably work really well here and would simplify the code to a series of SQL queries.

So you would make a hash table for every single possibility? That sounds very innefficient.


It is inefficient. I guess you don't have to populate an entire hash/array(I may have misinterpreted how your data is present in the file), but your program is still going to be insanely inefficient because you're searching through 1.3 million records in a flat text file, so you probably wouldn't notice much difference unless the record you're looking for happens to be near the top of the file.

 I think I see what you're saying but there's only about 2k of different lines that relate to the data.



fkusumot said:
 

I think I see what you're saying but there's only about 2k of different lines that relate to the data.


Turns out I *really* misunderstood then!  That should be piss easy.



The traditional web programming way to do this is to put your file into a SQL database (fairly easy to do with comma-separated values) and then do a query. Something like:

SELECT * FROM jewels WHERE serial_min = serial

A quick PHP for that would take about 10 minutes to write. Of course, you need SQL up and running on your server.