Link to home
Start Free TrialLog in
Avatar of Caiapfas
Caiapfas

asked on

I need a AUTOMATIC webpage maker..FAST

Ok, A little background : My site http://www.ticketstogo.com is a Online Event Ticket Website.
I need to have pages to every venue.. (But making everypage is slowwwwwww)
I have TRIED , TRIED and RETRIED to do this with Batch files, and javascript files which I'm a novice at..
I have a template at http://www.ticketstogo.com/venues/hobby_center.html
-----------------------------------------
and  a .cvs file with ALL(4000+) the link/venue ID's in (column A)
Example :
here is the link that displays the tickets in an IFrame
http://www.eventinventory.com/search/byevent.cfm?client=1555&restart=yes&v=2562
the VERY end is the link/venue ID >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-----------------------------------------
Also, the .cvs file has ALL the venues names(4000+)..in (column B)

So I need a Javascript file...or make be a Batch file that will do a find and replace on my template
c:\web\venuetemplate.htm
and find "XOX" and replace it with the venue name(Column B)
then change the end of the link in the IFrame with the VenueID(Column A)
and then copy and rename the venuetemplate.htm to c:\web\venues\VENUENAME.HTM
the rename needs to be in all lower case and spaces replaced with _ .... All tries to make this script has failed with errors, I'm to new to javascript..(extrnal file .js)

I'll give 1000 points easy!!

Thank YOU so much!!!!
Caiapfas
Avatar of aflat362
aflat362

Good lord.

You are in need of a real web programming language like ASP, JSP / Java, ColdFusion.

Avatar of Caiapfas

ASKER

I'm sure jsp = .js can do it. I need this to be a stand alone script. This is not for the web, only for the page creation on my pc.
Perl would work great at this.  I used to create 7000 dynamically static webpages a day in only 4 minutes using a .csv file from Excel.  You can do this on your local machine and then FTP your files to the server.
GREAT, can you help me write this script i'm ok in jsp(novice). but perl = 0
I need a template, and the .csv file.
ok, np....but how will i run the perl file? I rather it be .js file...I dont have perl installed...
email address?
What you need:
        Download Perl: http://downloads.activestate.com/ActivePerl/src/5.8/AP809_source.zip
        Load it on your computer

Then we can get started.
ok, where do i send the files?
Yes it can be done in .js. And also in Perl which is surely a nicer and more powerful language, however it doesn't come standard with Windows but that's not an issue here. You can even just write a VBA macro in excel for this.

Anyway, can you make the cvs and html template available for download on some of your web sites?
Thank you lbertacco!!!! You always the person I look for when it comes to .js
I really want it in .js its the language I'm most conformtable with...althought I know their are better ways and faster...

here is the .cvs file!
http://www.ticketstogo.com/aadownload/venues.csv

and the template
http://www.ticketstogo.com/aadownload/venuetemplate.htm
Something like this should do it:

var template = "C:\\template.htm";
var list = "C:\\cvs.txt";
var dstFolder = "E:\\tmp\\";

var fso =new ActiveXObject("Scripting.FileSystemObject");

//read template
var templFile = fso.OpenTextFile(template, 1);
var templText = templFile.ReadAll();
templFile.close();

//process venue list
var listFile = fso.OpenTextFile(list, 1);
while(!listFile.AtEndOfStream) {
      var line=listFile.ReadLine();
      var fields=line.split(";");
      var venueID=fields[0];
      var venueName=fields[1];      
      var fname=venueName.toLowerCase().replace(/ /g, "_") + ".htm";
      var dstFile = fso.CreateTextFile(fso.BuildPath(dstFolder, fname), true);
      dstFile.write(templText.replace(/_VENUE_NAME_/g, venueName).replace(/_VENUE_ID_/g, venueID));
      dstFile.close();
}
listFile.close();


Assumptions (that can be easily modified, anyway):
- the cvs file has venueID in first column, venueName in second column, separated by semicolon
- all cvs lines are data lines (no header, no empty lines)
- the strings searched in the template are _VENUE_NAME_ and _VENUE_ID_ (replaced with repsective values) and not XOX.
I posted the code before seeing you file, so there are a few things to be changed...give me a few minutes
Well almost there. Add line:
listFile.ReadLine(); //skip header
just before the "while" line.
Then replace ; with , in the line: var fields=line.split(";");
Set proper filenames in the first 3 lines
And finally modify your template using macros _VENUE_NAME_ and _VENUE_ID_ where you want them replaced.
Does it work?
What about the third cvs column (the state) ?
Also,  I save the .cvs file as text right?
and I made the request changes to the .html file.._VENUE_NAME_ and _VENUE_ID_

do you mind if we open 3 questions after this, 500 a peice?


Thank you
Caiapfas
i'm getting runtime error ... VenueName is null or not a object?


var template = "C:\\web\\AutoPageBuilder\\Templates\\venuetemplate.htm";
var list = "C:\\web\\AutoPageBuilder\\Data\\venues.txt";
var dstFolder = "C:\\web\\AutoPageBuilder\\Template\\venues\\";

var fso =new ActiveXObject("Scripting.FileSystemObject");

//read template
var templFile = fso.OpenTextFile(template, 1);
var templText = templFile.ReadAll();
templFile.close();

//process venue list
var listFile = fso.OpenTextFile(list, 1);
listFile.ReadLine(); //skip header
while(!listFile.AtEndOfStream) {
     var line=listFile.ReadLine();
     var fields=line.split(",");
     var VenueID=fields[0];
     var VenueName=fields[1];    
     var fname=VenueName.toLowerCase().replace(/ /g, "_") + ".htm";
     var dstFile = fso.CreateTextFile(fso.BuildPath(dstFolder, fname), true);
     dstFile.write(templText.replace(/_VENUE_NAME_/g, VenueName).replace(/_VENUE_ID_/g, VenueID));
     dstFile.close();
}
listFile.close();
lbertacco,

i'm getting runtime error ... VenueName is null or not a object?...

any help my friend..

Thank you,
Caiapfas
DrWarezz, I read the user agareement
https://www.experts-exchange.com/memberAgreement.jsp


I didnt see anything about not posting scripts?
could you point it out for me, knowing my dumba** i misread/over read it

Thank you,
Caiapfas
What's the full error information? Do you get any file created?

Beware that you have a few venues that translates to invalid filenames.
Among these:
first one: has empty name
second one: *** All Venues ***. Stars are not allowed in filenames
venue id 2128:colons are not allowed in filenames
How do you want to handle these? Either we skip them or change the naming convention or you fix them in the csv file.
Maybe this helps:
...
//process venue list
var listFile = fso.OpenTextFile(list, 1);
listFile.ReadLine(); //skip header
while(!listFile.AtEndOfStream) {
  var line=listFile.ReadLine();
  var fields=line.split(",");
  try {
    var VenueID=fields[0];
    var VenueName=fields[1];    
    var fname=VenueName.toLowerCase().replace(/ /g, "_") + ".htm";
    var dstFile = fso.CreateTextFile(fso.BuildPath(dstFolder, fname), true);
    dstFile.write(templText.replace(/_VENUE_NAME_/g, VenueName).replace(/_VENUE_ID_/g, VenueID));
    dstFile.close();
   }
   catch(e) {
    WScript.echo("Error processing venue id " + VenueID + " with name '" + VenueName + "'");
   }
                 
}
listFile.close();
skip the bad lines,

error message :

(20,2)Microsoft Jscript runtime error : "VenueName" is null or not an object
ok now, its getting stuck in a loop going so fast i cant read it

Error processing venue id (numder) (name) (state) with name 'undifined'
over and over and over and over untill its all the way throught the csv file
If you still get the error, try adding after line: var line=listFile.ReadLine();
WScript.StdOut.WriteLine("processing line: " + line);
then run the script with
CSCRIPT scripname.js
What output do you get? Do you get any file correctly created?
(maybe we have a different cscript version. I have cscript v5.6. Run cscript/? to find out)

Do you see the venue IDs? Just not the venue names?
Do you use commas to separate the values in the csv files?
no its tab delimited.
 yes, i see the names and id's in the errors...
Well the script assumed commas as separators (your file from http://www.ticketstogo.com/aadownload/venues.csv used commas).
For tabs replace
  var fields=line.split(",");
with
  var fields=line.split("\t");
so do i make it read the .csv file or save it as a text file?
not instead of this
Error Proccing Venue Id (whatever) with name '(whatever)' with name 'undifined'
I'm geeting
Error Proccing Venue Id (whatever) with name '(whatever)'

it goes through EVERYLINE , before it stops


i'm running cscript 5.6 also
i saved it as a text file , and right now making it read the .txt file, should i make it read the .csv?
The csv file you posted online was fine (it used commas as sperator so you need to use split(",") for it).
If you keep getting errors, please post online exactly the files you are using (template, csv, script).


lbertacco,

Any progress? I have been trying on this end ,but keep getting the same errors..

Caiapfas
lbertacco, Also is it possible to have a .js file to resize images and save them making them smaller? If it is I will open a new question.

Thank you, for all you help.
any luck on the script?
ASKER CERTIFIED SOLUTION
Avatar of lbertacco
lbertacco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It works perfect, thanks again, my friend
3400 pages in 1 min, oo yea....thank you, thank you
I can change the templates layout anytime as long as i keep
_VENUE_NAME_ and _VEUNE_ID_
right?

Sure :-)