473,383 Members | 1,874 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,383 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 38491
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.