Read Last Row From File with EL Collections  [SOLVED]

Questions about MultiCharts and user contributed studies.
Posts: 22
Joined: 18 May 2018
Has thanked: 7 times

Read Last Row From File with EL Collections

Postby Parker » 25 Jun 2018

Does anyone know how to read the last row from a file with EL Collections?

I am reading in a standard csv file. I have managed to figure out how to point at certain row numbers. But what happens if you don't know how many records are in the file. There is no end of file marker in my data. I have tried to use while loops but I can't get anything to work successfully. There must be a simple way of doing it that I have missed.

Here is my code (pointing at row 2 of the file):

Code: Select all

if CurrentBar = 1 then Begin

ListC_ID =;
Value1 = ListC.ReadFile(ListC_ID,Filename);

//virtual column names
Date_ID = ListC.Get(ListC_ID,1);
Time_ID = ListC.Get(ListC_ID,2);
Strategy_ID = ListC.Get(ListC_ID,3);
MP_ID = ListC.Get(ListC_ID,7);
mContracts_ID = ListC.Get(ListC_ID,8);

//read rows
Date_ = ListS.Get(Date_ID,2 );
Time_ = ListS.Get(Time_ID,2 );
Strategy_ = ListS.Get(Strategy_ID,2 );
MP_ = ListS.Get(MP_ID,2 );
mContracts_ = ListS.Get(mContracts_ID,2 );

Print("Date_=",Date_," | Time_=",Time_," | MP_=",MP_," | mContracts_=",mContracts_);



User avatar
Posts: 626
Joined: 16 Dec 2006
Has thanked: 119 times
Been thanked: 355 times

Re: Read Last Row From File with EL Collections

Postby ABC » 26 Jun 2018

Hi Parker,

since you have the entire file in lists already, you can use ListX.Count (where X is the type of list) to determine the size of a list and then read the specific entry.


These users thanked the author ABC for the post:

Posts: 22
Joined: 18 May 2018
Has thanked: 7 times

Re: Read Last Row From File with EL Collections  [SOLVED]

Postby Parker » 26 Jun 2018


Thanks yes this has worked great.

This has actually also helped me to understand better what the code is doing. I ran ListX.Count on the ListC_ID variable which gives the number of columns. Then ran it Date_ID and it gives me the number of records. I had adapted this code from some forum posts but now I am clear that it reads in the columns into the first list and then the values into each list one for each column.


Return to “MultiCharts”