Import ASCII file into a HTML form

liunx

Guest
I've written a program to write a file containing the results of various calculations. I'd like to display the results in a HTML format. <br />
<br />
I need to import a ASCII file , rows of data into specific field in the HTML file.<br />
<br />
Can anyone lead me in the right direction?<br />
<br />
:o<!--content-->What kind of ascii file? .txt? I think a server side language is what you need here, Perl or PHP. Does your server support PHP?<!--content-->Perl, being the Practical Extraction and Report Language, would do a very nice job in a minimum number of lines.<!--content-->I can name the file anything I want. I currently use .CAL (calc). Is there an advantage to use TXT?<!--content-->No, probably not, I was just wondering what kind of info you'd have in it. All you need to do is display the text file in you html file?<!--content-->Below is an example of a file I write.<br />
<br />
<br />
5555599<br />
1HS1<br />
18<br />
7.95<br />
1264<br />
1962<br />
20<br />
HS2-1,53,125.00,22.35,6.89, *<br />
HS2-2,33,89.00,21.38,10.91,**<br />
HS2-3,139,89.00,17.52,27.00,**<br />
HS2-4,35,89.00,16.60,30.85,**<br />
HS2-5,57,89.00,15.17,36.78,**<br />
HS2-6,17,100.00,14.77,38.45,**<br />
HS2-7,67,89.00,13.30,44.58,**<br />
HS2-8,56,100.00,12.15,49.37,**<br />
<br />
<eof><br />
<br />
I would like to read the file and place the data into specific fields in the form. In the ideal world, I'd like to save the data into a specific HTML file with the same name as the .CAL file.<br />
But I might be asking for too much.<br />
<br />
I need some way to send the data to the client in a easy readable format for them to review and approve.<!--content-->It should be quite easily done in PHP... Or, just to let you know that you can, you can load a .txt file into an iFrame, but that won't allow you to split into form fields, etc.<!--content-->Do you know where I can find an example of this? I know a little about HTML but have never written PHP before. Any resource ideas would be great.<br />
<br />
Thanks for your time and input.<!--content-->This seems more and more like a job for Perl. And you can use the CGI.pm module to greatly simplify the HTML part of the problem. I'd toss something together for you but I don't know what those number represent or how you want the HTML file look. <br />
<br />
But if you had written the calculator program in Perl from the start, then you'ld be one step closer. Perl was designed for this kind of thing and only later pressed into service for the web.<!--content-->I am performing the calculations within AutoCAD, using LISP. Then I write the results out to a file.<br />
<br />
Below you will the description of the fields.<br />
<br />
<br />
Project number: 5555599<br />
Circuit: 1HS1<br />
Wire guage: 18<br />
Resistence: 7.95 per 1000 feet<br />
Total conduit length: 1264,feet<br />
Total mAmp in circuit: 1962,mAmp<br />
Total number of devices: 20<br />
<br />
Device ID Length mAmp Volts % Drop<br />
HS2-1 53 125.00 22.35 6.89 *<br />
HS2-2 33 89.00 21.38 10.91 **<br />
HS2-3 139 89.00 17.52 27.00 **<br />
HS2-4 35 89.00 16.60 30.85 **<br />
HS2-5 57 89.00 15.17 36.78 **<br />
HS2-6 17 100.00 14.77 38.45 **<br />
HS2-7 67 89.00 13.30 44.58 **<br />
HS2-8 56 100.00 12.15 49.37 **<br />
<br />
* Greater than 5% voltage drop<br />
** Greater than 10% voltage drop<br />
<br />
<br />
If you can just get ME started, I would appreciate it.<br />
(sorry for the typo)<br />
<br />
Thanks for your help.<!--content-->If you're going to use Perl/CGI, you'll need to find help from someone besides me. It's not my strong suit. I always use PHP if it is an option. :D<!--content-->At this point I'll try PHP. If you have some input I'd like to hear/see it.<br />
<br />
Thanks<!--content-->Something like this ought to do the trick.<br />
<br />
use strict;<br />
use CGI qw(:all acronym);<br />
<br />
my $projectNumber = <>;<br />
chomp $projectNumber;<br />
<br />
my $circuit = <>;<br />
chomp $circuit;<br />
<br />
my $wireGauge = <>;<br />
chomp $wireGauge;<br />
<br />
my $resistance = <>;<br />
chomp $resistance;<br />
<br />
my $conduitLength = <>;<br />
chomp $conduitLength;<br />
<br />
my $mAmp = <>;<br />
chomp $mAmp;<br />
<br />
my $devices = <>;<br />
chomp $devices;<br />
<br />
my @data = <>;<br />
<br />
my $acronym = acronym({-title=>'miliamp'}, 'mAmp');<br />
my $project = Tr(th('Project Number'), td($projectNumber));<br />
$project = $project.Tr(th('Circuit'), td($circuit));<br />
$project = $project.Tr(th('Wire guage'), td($wireGauge));<br />
$project = $project.Tr(th('Resistence per 1000 feet'), td($resistance));<br />
$project = $project.Tr(th('Total conduit length'), td($conduitLength));<br />
$project = $project.Tr(th("Total $acronym in circuit"), td($mAmp));<br />
$project = $project.Tr(th('Total number of devices'), td($devices));<br />
$project = table($project);<br />
<br />
my $data = Tr(th(['Device ID', 'Length', 'mAmp', 'Volts', '% Drop', '&nbsp;']));<br />
foreach (@data) {chomp; my @td = split /,/; $data = $data.Tr(td(\@td))};<br />
$data = table($data);<br />
<br />
my $title = "Data for $projectNumber";<br />
<br />
print start_html($title), h1($title), $project, $data, end_html;<!--content-->Seeing how Charles is willing to help you with a Perl version, go ahead and use that...<!--content-->I think I see what's going on.<br />
<br />
Thanks to both of you........<br />
<br />
I really appreciate it.<br />
<br />
Thanks<!--content-->
 
Back
Top