HELP on How to read CSV file content into Array 
Author Message
 HELP on How to read CSV file content into Array

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



Mon, 07 Apr 2003 03:00:00 GMT  
 HELP on How to read CSV file content into Array

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++;

Quote:
}

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];
 }
Quote:
}

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

Quote:

> 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



Tue, 08 Apr 2003 13:44:10 GMT  
 HELP on How to read CSV file content into Array

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++;

Quote:
}

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];
 }
Quote:
}

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

Quote:
> 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



Tue, 08 Apr 2003 03:00:00 GMT  
 HELP on How to read CSV file content into Array

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



Tue, 08 Apr 2003 03:00:00 GMT  
 HELP on How to read CSV file content into Array

Thanks I will give a try.

Base on this ActiveXControl object, what library does it require if I want
to use my created script on an other machine.
If I use it like this I ghet error "Automation server not found" error
message.

Thanks for your help



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



Fri, 11 Apr 2003 03:00:00 GMT  
 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



Fri, 11 Apr 2003 03:00:00 GMT  
 HELP on How to read CSV file content into Array

It requires the Windows JScript engine, which is installed with IE 5+. It can also be downloaded.
http://www.microsoft.com/msdownload/VBScript/scripting.asp

You other post is abut using anchor tags. A look at the A tag docs will show you how to create and use them.

--
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 I will give a try.

> Base on this ActiveXControl object, what library does it require if I want
> to use my created script on an other machine.
> If I use it like this I ghet error "Automation server not found" error
> message.

> Thanks for your help



> 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


> > 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



Fri, 11 Apr 2003 03:00:00 GMT  
 HELP on How to read CSV file content into Array
THanks again for your help which is appreciate.

I will still disturn you to another point.
I mange to get links working between my frames by dynamically defineing
Bookmark and reference to them, but what I have noticed using debuger is
that when I press on the links to be able to scroll to corresponding topic
on right frame, the complete loading procedure of the page is executed
again.

Is it normal behaviour, if not what is behaves like that ?

For me it is logic that when a page is loaded once you just scrool inside
that page and nom need to load again.

Thanks again
Serge



It requires the Windows JScript engine, which is installed with IE 5+. It
can also be downloaded.
http://www.microsoft.com/msdownload/vbscript/scripting.asp

You other post is abut using anchor tags. A look at the A tag docs will show
you how to create and use them.

--
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 I will give a try.

> Base on this ActiveXControl object, what library does it require if I want
> to use my created script on an other machine.
> If I use it like this I ghet error "Automation server not found" error
> message.

> Thanks for your help



> 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


> > 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



Sat, 12 Apr 2003 03:00:00 GMT  
 HELP on How to read CSV file content into Array

Your link WILL reload the page, but the browser might retrieve it from
it's local cache, instead of from the server ...

Hans Kesting


Quote:
> THanks again for your help which is appreciate.

> I will still disturn you to another point.
> I mange to get links working between my frames by dynamically defineing
> Bookmark and reference to them, but what I have noticed using debuger is
> that when I press on the links to be able to scroll to corresponding topic
> on right frame, the complete loading procedure of the page is executed
> again.

> Is it normal behaviour, if not what is behaves like that ?

> For me it is logic that when a page is loaded once you just scrool inside
> that page and nom need to load again.

> Thanks again
> Serge



Sat, 12 Apr 2003 03:00:00 GMT  
 HELP on How to read CSV file content into Array
Thanks for the info.

I have one stuff which disturb me:
I amd using ActiveXObject("Scripting.FileSystemObject") for accessing to
files, and at that time I have this security message from explorer which
comes all the times before page gets loaded.

How can I get ride of it

Thanks
serge


Quote:
> Your link WILL reload the page, but the browser might retrieve it from
> it's local cache, instead of from the server ...

> Hans Kesting



> > THanks again for your help which is appreciate.

> > I will still disturn you to another point.
> > I mange to get links working between my frames by dynamically defineing
> > Bookmark and reference to them, but what I have noticed using debuger is
> > that when I press on the links to be able to scroll to corresponding
topic
> > on right frame, the complete loading procedure of the page is executed
> > again.

> > Is it normal behaviour, if not what is behaves like that ?

> > For me it is logic that when a page is loaded once you just scrool
inside
> > that page and nom need to load again.

> > Thanks again
> > Serge



Sat, 12 Apr 2003 03:00:00 GMT  
 HELP on How to read CSV file content into Array
I have pste my script inside a js file and I still have the security
message.
I have rename all my HTM file as HTA and I get the download dialog box all
time page load.

Any other ideas for this ecurity message

thanks
br
serge



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



Mon, 14 Apr 2003 23:40:22 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Help reading CSV files

2. Reading a comma separated variable file? (.csv file)

3. Read a CSV-file with vbscript

4. How to read a CSV file in ASP

5. Reading from CSV file using VBScript.......

6. Read CSV file containing quotes

7. Reading a CSV File

8. Read a CSV-file with vbscript

9. How to read a CSV file from a VBS Script

10. Using CSV or CST text files how do you associate a column to the array

11. Insert csv Text File ino Array?

12. help reading contents of folder

 

 
Powered by phpBB® Forum Software