Am trying to put together a simple JavaScript to eventually use with AmiBroker. 
 This JavaScript should ...

1. Start out with the before.csv file.
A,B,C,D,E,F,G,H,I,J
5,4,3,2,1,10,9,7,6,6

2. Skip the first line and read the 10 numbers into an array.

3. Write this array to a new after.csv file.

I am lost with all of my googling.  Here is what I have.  Help appreciated.

var myarray = new Array();
var fso, ts, ts2, i;

var ForReading = 1, ForWriting = 2, ForAppending = 8;
var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;

var before = "C:\\Amibroker\\Temp\\before.csv"
var after = "C:\\Amibroker\\Temp\\after.csv"

fso = new ActiveXObject("Scripting.FileSystemObject");
//object.OpenTextFile(filename, iomode, create, format)
ts = fso.OpenTextFile(before, ForReading, false, TristateUseDefault);

//ts.SkipLine();
//ts.ReadLine();
//myarray = ts.split(',');

for (i = 1; i <= 10; i++)
{
ts.ReadLine();
//ts.ReadLine();
ts.ReadLine(myarray[i]);
}

ts.Close();


ts2 = fso.OpenTextFile(after, ForWriting, true, TristateUseDefault);
ts2.Write(myarray + ',');
ts2.Close();
// The end

Reply via email to