
HELP on How to read CSV file content into Array
Sorry, I forgot one question also.
As soon as I am able to get the content of the CSV file (which has actually
in my case 2 fields), what is the best way to display on a left frame the
content of filed 1 and on the right frame the content of field 2.
I am actually building frame as follow but not sure it is correct :
<FRAMESET COLS="30%,*">
<FRAME NORESIZE=NORESIZE SRC="param.htm" NAME "Param">
<FRAME NORESIZE=NORESIZE SRC="descr.htm" NAME "Descr">
</FRAMESET>
In an other HTML file (function.htm) I have all needed function to be called
as :
ReadFile()
GetFieldIntoArray()
DisplayData()
The problem that I met here is that param.html and descr.htm need to call
same function to be able to filled up the page.
ReadFile funtion is getting lines from file
GetFieldIntoArray is putting lines into array
DisplayData is putting on the page value from array
After that what I would like to do is automatically create links from
param.html page to Descr.html
In other words when clicking on Item1 of left frame, I should scroll my page
in right frame to proper topic
THanks for your comments and experience of that issue, I appreciate a lot if
you could give me a good approach as I am quite new in this area.
Thanks a lot
Regards
CALDERARA Serge
Nextrom S.A
I notice my code uses 'rec-1' instead of 'num' in the last two for loops, in
error.
Security is a browser feature that IE does very well. It does not allow
script to run exe's or access files on the client. My example, created as a
stand-alone file named "myfile.js" would not give the Active X warning.
Alternatively, naming an HTML page as *.HTA would run the page in a local
security-less browser.
Accessing a CSV file stored on the client, from code on a web page is
restricted to obtaining client permission, for obvious reasons.
--
Mark L. Ferguson Reply Only in Newsgroup
marfer's notes for OE 5.0 >
http://www.geocities.com/marfer_mvp/IE_ng_notes.htm
Quote:
> Thanks a lot for your support.
> By the way I have notice that when using this
> ActiveXObject("scripting.FiuleSystemObjet"), a security message appear
about
> activX controls, what is the reason for that and how to avoid ?r disable
> that message.
> Thanks
> CSV to alert
> var fso = new ActiveXObject("Scripting.FileSystemObject");
> var f = fso.OpenTextFile("mycsv.csv");
> var temp = "";
> var list = new Array();
> var fields = new Array();
> var rec = 1;
> var count = 0;
> while(!f.AtEndOfStream) {
> temp = f.ReadLine();
> fields = temp.split(",");
> for(i=0; i < fields.length; i++) {
> list[count++] = fields[i];
> }
> rec++;
> }
> count = 0;
> var num = list.length/(rec - 1);
> var group = new Array();
> for(k=1; k < rec; k++) {
> for(m=1; m < (num + 1); m++) {
> group[count++] = list[k + (m * num) - num - 1];
> }
> }
> count=0;
> WScript.Echo(list.toString())
> WScript.Echo(group.toString())
> var set1 = new Array();
> for(r=0; r < (rec - 1); r++) {
> set1[r] = group[count++];
> }
> WScript.Echo(set1.toString());
> var set2 = new Array();
> for(r=0; r < (rec - 1); r++) {
> set2[r] = group[count++];
> }
> WScript.Echo(set2.toString());
> --
> Mark L. Ferguson Reply Only in Newsgroup
> marfer's notes for OE 5.0 >
> http://www.geocities.com/marfer_mvp/IE_ng_notes.htm
> > Dear all,
> > Does anyone has example or can give me a tips on how can I read data
from
> a
> > CSV file and put different fields of the file inside an Array for future
> > use. All of this using Javascript.
> > Thanks for your prompt answer
> > CALDERARA Serge
> > NExtrom S.A