473,425 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,425 software developers and data experts.

Getting data from a text file

Hi,

I have two files in a directory.
one called toto.txt with the following content :
1
2
3
4
5

one called toto.html in which I want to get the data of toto.txt with a
javascript script.

May you suggest me an example of a script doing this ?

Regards.

Jean-Marie
Jul 20 '05 #1
4 38496
alu
if the data file does not necessarily need to have a .txt extension, it
would be better to rename it toto.js (you can still open it in notepad)

within toto.js you'll need to assign variables for the data,
for example in the simplest way:

mydata1 = 1
mydata2 = 2
mydata3 = 3
mydata4 = 4
mydata5 = 5
then it's just a matter of including & using the variables within toto.html,
for example:

<script src="toto.js" type="text/javascript"></script>

<script Language='JavaScript'>
document.write(mydata1)
</script>
if you must have the data in a .txt extension file, it may still work:

<script src="toto.txt" type="text/javascript"></script>

<script Language='JavaScript'>
document.write(mydata1)
</script>

----------------------------------------------------------------------------

"Jean-Marie Delapierre" <je*******************@wanadoo.fr> wrote in message
news:pa****************************@wanadoo.fr...
Hi,

I have two files in a directory.
one called toto.txt with the following content :
1
2
3
4
5

one called toto.html in which I want to get the data of toto.txt with a
javascript script.

May you suggest me an example of a script doing this ?

Regards.

Jean-Marie


Jul 20 '05 #2
Le Fri, 10 Oct 2003 18:37:38 -0400, alu a écrit*:
if the data file does not necessarily need to have a .txt extension, it
would be better to rename it toto.js (you can still open it in notepad)

within toto.js you'll need to assign variables for the data,
for example in the simplest way:

mydata1 = 1
mydata2 = 2
mydata3 = 3
mydata4 = 4
mydata5 = 5
then it's just a matter of including & using the variables within toto.html,
for example:

<script src="toto.js" type="text/javascript"></script>

<script Language='JavaScript'>
document.write(mydata1)
</script>
if you must have the data in a .txt extension file, it may still work:

<script src="toto.txt" type="text/javascript"></script>

<script Language='JavaScript'>
document.write(mydata1)
</script>

----------------------------------------------------------------------------

"Jean-Marie Delapierre" <je*******************@wanadoo.fr> wrote in message
news:pa****************************@wanadoo.fr...
Hi,

I have two files in a directory.
one called toto.txt with the following content :
1
2
3
4
5

one called toto.html in which I want to get the data of toto.txt with a
javascript script.

May you suggest me an example of a script doing this ?

Regards.

Jean-Marie


Hi,

Thank you very mutch for your answer.
But, your solution can't work for me. The text file (here is only a basic
exemple) will be generated by an Excel extract.
Therefore, I have no possibility to transform it into a javascript script
assigning data to variables.

Regards.

Jean-Marie
Jul 20 '05 #3
Hi,

Jean-Marie Delapierre wrote:

"Jean-Marie Delapierre" <je*******************@wanadoo.fr> wrote in message
news:pa****************************@wanadoo.fr.. .
Hi,

I have two files in a directory.
one called toto.txt with the following content :
1
2
3
4
5

one called toto.html in which I want to get the data of toto.txt with a
javascript script.

May you suggest me an example of a script doing this ?

Regards.

Jean-Marie

Hi,

Thank you very mutch for your answer.
But, your solution can't work for me. The text file (here is only a basic
exemple) will be generated by an Excel extract.
Therefore, I have no possibility to transform it into a javascript script
assigning data to variables.

Regards.

Jean-Marie


I assume that you have access to the Excel file. If so, why not simply
make a VB macro saving the text file in any format you decide?

If you really don't have this possibility, one possible way is to have a
Java applet read the text file, and pass the content to JS for
processing. See examples and a free download at
http://www.galasoft-LB.ch/myjava/Web...Demo/Demo.html

Other ways include (if the application runs locally only) using the
FileSystemObject (IE only) or directly accessing the java File object
(Netscape only). All these solutions need lower security settings, and
not very easy to put in place.

I would try the macro solution first.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #4
alu

"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in
message news:3f**********@news.bluewin.ch...
Hi,

Jean-Marie Delapierre wrote:

"Jean-Marie Delapierre" <je*******************@wanadoo.fr> wrote in messagenews:pa****************************@wanadoo.fr.. .

Hi,

I have two files in a directory.
one called toto.txt with the following content :
1
2
3
4
5

one called toto.html in which I want to get the data of toto.txt with a
javascript script.

May you suggest me an example of a script doing this ?

Regards.

Jean-Marie

Hi,

Thank you very mutch for your answer.
But, your solution can't work for me. The text file (here is only a basic exemple) will be generated by an Excel extract.
Therefore, I have no possibility to transform it into a javascript script assigning data to variables.

Regards.

Jean-Marie


I assume that you have access to the Excel file. If so, why not simply
make a VB macro saving the text file in any format you decide?

If you really don't have this possibility, one possible way is to have a
Java applet read the text file, and pass the content to JS for
processing. See examples and a free download at
http://www.galasoft-LB.ch/myjava/Web...Demo/Demo.html

Other ways include (if the application runs locally only) using the
FileSystemObject (IE only) or directly accessing the java File object
(Netscape only). All these solutions need lower security settings, and
not very easy to put in place.

I would try the macro solution first.

HTH,

Laurent
--

I agree, the Excel solution should be easy.
I'm not very familiar with Excel, but i would think that just adding 2
columns
to the left of the required data and then extracting all three columns
would do the trick.
e.g.,

="mydata"&ROW() = [data to extract]

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: projecktzero | last post by:
Well, I've managed to get an image into a postgre database, but now I'm having trouble getting it out. #! /usr/bin/env python from pyPgSQL import PgSQL def main(): connectdb =...
2
by: N. Graves | last post by:
I'm planning to develop a process to import data from an external flat file to a new table automatically. As usual I'm having a hard time getting started on the solution because of the Access's...
4
by: Sean Shanny | last post by:
To all, Running into an out of memory error on our data warehouse server. This occurs only with our data from the 'September' section of a large fact table. The exact same query running over...
1
by: thangchan | last post by:
Hi all, i am getting SQL update problem. as below ======================error messages ======================= Server Error in '/CMS' Application....
0
by: sags | last post by:
Hi , Iam a new uesr of this group. I have a small doubt . Iam using the code mentioned below to retrive the data from tab delimited text file ., but Iam getting all the columns of the text file...
10
by: eggie5 | last post by:
Is it possible to get a file without using a form post? I want to get the data (bytes) of a file, text or binary, and just save it to a variable. Similar to the post body of a form that has a...
3
by: tshad | last post by:
I have a file that I converted from VB.Net to C# that works fine in VB.Net when I compile but not in C# using the same libraries. The error I am getting is: PageInit.cs(9,7): error CS0138: A...
0
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.