Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: looking for aps code to access ascii text files


Message #1 by "Eva Olak" <ewa.olak@j...> on Mon, 22 Jul 2002 16:25:21
Hello,

I am looking for a code how to open and read ASCII text file, delimited 
with commas. The content of the file has to be then displayed on the web  
formatted as a report.

The file has the following layout:
date( in the format yyyymmdd), string, string, string, string, string 
Below is the example of one row of the file:
20020710, "SomeString", "SomeString", "SomeString", "SomeString", "SomeStri
ng".

The books and web sites I was looking at have lots of examples how to open 
the databases but not flat text files.  Would anyone has a code to share ?

Thanks a lot
Eva
Message #2 by Jack_Speranza <jsperanza@g...> on Mon, 22 Jul 2002 11:19:00 -0400
Try searching for info on using the File Scripting Object (FSO), accessible
via the Scripting Engine Runtime DLL.  You should find plenty of info both
on the wrox site as well as on others.

Cheers,

Jack

-----Original Message-----
From: Eva Olak [mailto:ewa.olak@j...]
Sent: Monday, July 22, 2002 12:25 PM
To: ASP Web HowTo
Subject: [asp_web_howto] looking for aps code to access ascii text files


Hello,

I am looking for a code how to open and read ASCII text file, delimited 
with commas. The content of the file has to be then displayed on the web  
formatted as a report.

The file has the following layout:
date( in the format yyyymmdd), string, string, string, string, string 
Below is the example of one row of the file:
20020710, "SomeString", "SomeString", "SomeString", "SomeString", "SomeStri
ng".

The books and web sites I was looking at have lots of examples how to open 
the databases but not flat text files.  Would anyone has a code to share ?

Thanks a lot
Eva

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
Message #3 by "TomMallard" <mallard@s...> on Mon, 22 Jul 2002 08:25:47 -0700
Create an data source from it as text/csv (comma separated list), this can
be done using ODBC and  allows the first row to be column names for most
drivers. You can then connect to it using ADO and access the data as a table
and define datatypes directly.

You can also use the filesystemobject...more work, split()'ing the file to
an array to use for processing. In your sample: split(strInput, """, """)

tom mallard
seattle

-----Original Message-----
From: Eva Olak [mailto:ewa.olak@j...]
Sent: Monday, July 22, 2002 4:25 PM
To: ASP Web HowTo
Subject: [asp_web_howto] looking for aps code to access ascii text files


Hello,

I am looking for a code how to open and read ASCII text file, delimited
with commas. The content of the file has to be then displayed on the web
formatted as a report.

The file has the following layout:
date( in the format yyyymmdd), string, string, string, string, string
Below is the example of one row of the file:
20020710, "SomeString", "SomeString", "SomeString", "SomeString", "SomeStri
ng".

The books and web sites I was looking at have lots of examples how to open
the databases but not flat text files.  Would anyone has a code to share ?

Thanks a lot
Eva

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

Message #4 by "Larry Woods" <larry@l...> on Mon, 22 Jul 2002 08:52:50 -0700
Look for "File SYSTEM Object"

Larry Woods


> -----Original Message-----
> From: Jack_Speranza [mailto:jsperanza@g...]
> Sent: Monday, July 22, 2002 8:19 AM
> To: ASP Web HowTo
> Subject: [asp_web_howto] RE: looking for aps code to
> access ascii text
> fil es
>
>
> Try searching for info on using the File Scripting
> Object (FSO), accessible
> via the Scripting Engine Runtime DLL.  You should find
> plenty of info both
> on the wrox site as well as on others.
>
> Cheers,
>
> Jack
>
> -----Original Message-----
> From: Eva Olak [mailto:ewa.olak@j...]
> Sent: Monday, July 22, 2002 12:25 PM
> To: ASP Web HowTo
> Subject: [asp_web_howto] looking for aps code to
> access ascii text files
>
>
> Hello,
>
> I am looking for a code how to open and read ASCII
> text file, delimited
> with commas. The content of the file has to be then
> displayed on the web
> formatted as a report.
>
> The file has the following layout:
> date( in the format yyyymmdd), string, string, string,
> string, string
> Below is the example of one row of the file:
> 20020710, "SomeString", "SomeString", "SomeString",
> "SomeString", "SomeStri
> ng".
>
> The books and web sites I was looking at have lots of
> examples how to open
> the databases but not flat text files.  Would anyone
> has a code to share ?
>
> Thanks a lot
> Eva
>
> ---
>
> Improve your web design skills with these new books
> from Glasshaus.
>
> Usable Web Menus
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=n
osim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/thepr
ogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/thepr
ogramme
r-20


---

Improve your web design skills with these new books from
Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/thepr
ogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/thepr
ogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/thepr
ogramme
r-20

Message #5 by "Drew, Ron" <RDrew@B...> on Mon, 22 Jul 2002 17:35:44 -0400
Change the GetFile to your filename or use Server.MapPath
Do a split on strFil below to build your array....

<%@ Language=3DJScript %>
<HTML><HEAD><TITLE>FileSystemObject Sample Page</TITLE></HEAD>
<BODY>
<%
//Constants for Script parameters
var ForReading =3D 1;
// Newline var consists of HTML <BR> tag plus a JScript newline.
var NewLine =3D "<BR>\n";

// Create a FileSystemObject.
var fso, ts;
fso =3D new ActiveXObject("Scripting.FileSystemObject");

' Access an existing file and its attributes--Name, Path, and
DateLastModified.
ts =3D fso.GetFile("c:\\fileshare\\test.txt");
Response.Write("Your file's name is: " + ts.Name + NewLine);
Response.Write("Your file's path is: " + ts.Path + NewLine);
Response.Write("File last changed: " + ts.DateLastModified);

' Open the file and read data from it. Notice that when you call
'OpenTextFile, you set the overwrite parameter to "false," so you
'use the existing file instead of creating a new one.

var strFil =3D NewLine + ""
ts =3D fso.OpenTextFile("c:\\fileshare\\test.txt",ForReading,false);

'Loop through lines in the file, read them into strFil variable.
while (!ts.AtEndOfStream) {
   strFil +=3D ts.ReadLine() + NewLine;
}

// Write the variable containing the file contents into the page.
Response.Write(NewLine + strFil);
ts.Close();

%>
</BODY></HTML>

-----Original Message-----
From: Eva Olak [mailto:ewa.olak@j...]
Sent: Monday, July 22, 2002 12:25 PM
To: ASP Web HowTo
Subject: [asp_web_howto] looking for aps code to access ascii text files


Hello,

I am looking for a code how to open and read ASCII text file, delimited
with commas. The content of the file has to be then displayed on the web

formatted as a report.

The file has the following layout:
date( in the format yyyymmdd), string, string, string, string, string
Below is the example of one row of the file:
20020710, "SomeString", "SomeString", "SomeString", "SomeString",
"SomeStri ng".

The books and web sites I was looking at have lots of examples how to
open
the databases but not flat text files.  Would anyone has a code to share
?

Thanks a lot
Eva

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20
Message #6 by "Eva Olak" <ewa.olak@j...> on Tue, 23 Jul 2002 02:53:20
> Change the GetFile to your filename or use Server.MapPath
Do a split on strFil below to build your array....

<%@ Language=3DJScript %>
<HTML><HEAD><TITLE>FileSystemObject Sample Page</TITLE></HEAD>
<BODY>
<%
//Constants for Script parameters
var ForReading =3D 1;
// Newline var consists of HTML <BR> tag plus a JScript newline.
var NewLine =3D "<BR>\n";

// Create a FileSystemObject.
var fso, ts;
fso =3D new ActiveXObject("Scripting.FileSystemObject");

' Access an existing file and its attributes--Name, Path, and
DateLastModified.
ts =3D fso.GetFile("c:\\fileshare\\test.txt");
Response.Write("Your file's name is: " + ts.Name + NewLine);
Response.Write("Your file's path is: " + ts.Path + NewLine);
Response.Write("File last changed: " + ts.DateLastModified);

' Open the file and read data from it. Notice that when you call
'OpenTextFile, you set the overwrite parameter to "false," so you
'use the existing file instead of creating a new one.

var strFil =3D NewLine + ""
ts =3D fso.OpenTextFile("c:\\fileshare\\test.txt",ForReading,false);

'Loop through lines in the file, read them into strFil variable.
while (!ts.AtEndOfStream) {
   strFil +=3D ts.ReadLine() + NewLine;
}

// Write the variable containing the file contents into the page.
Response.Write(NewLine + strFil);
ts.Close();

%>
</BODY></HTML>

-----Original Message-----
From: Eva Olak [mailto:ewa.olak@j...]
Sent: Monday, July 22, 2002 12:25 PM
To: ASP Web HowTo
Subject: [asp_web_howto] looking for aps code to access ascii text files


Hello,

I am looking for a code how to open and read ASCII text file, delimited
with commas. The content of the file has to be then displayed on the web

formatted as a report.

The file has the following layout:
date( in the format yyyymmdd), string, string, string, string, string
Below is the example of one row of the file:
20020710, "SomeString", "SomeString", "SomeString", "SomeString",
"SomeStri ng".

The books and web sites I was looking at have lots of examples how to
open
the databases but not flat text files.  Would anyone has a code to share
?

Thanks a lot
Eva

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20

  Return to Index