Line reading in a CSV file

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Line reading in a CSV file

Postby arjfca » 27 Apr 2012

Hello

RE: Reading line by line a csv file:

I'm gathering information before I start to code this weekend. I want to read line by line a csv file to get all my traded orders during the day. The goal is to show them using arrow on my charts. I don't trade via MC, so I don't have them in MC file.

I will read the file with Elcollection and save it as a string. I know how to read each column in a line using my function splitstring viewtopic.php?f=5&t=8950&p=42264#p42264

Now,
- How do i read individual line. Is there a code to look for for a new line?
- Is there a value to look for that indicate the end of the file?

- Is the Elcollection will be available in the 64 version?

Any info appreciate

Martin

User avatar
TJ
Posts: 7743
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Line reading in a CSV file

Postby TJ » 27 Apr 2012

Hello

...

- Is the Elcollection will be available in the 64 version?

Any info appreciate

Martin
viewtopic.php?f=16&t=10094

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Line reading in a CSV file

Postby JoshM » 28 Apr 2012

I will read the file with Elcollection and save it as a string.

(..)

- How do i read individual line. Is there a code to look for for a new line?
This is not needed, since the ELCollection reads the whole file with ListN.ReadFile() or ListS.ReadFile(). You will then need to use the ListX.Count(ID) function to get the length of the list, and then you can loop through it.

In other words, you can't specify the line that needs to be read, but you first have to import the file, and then you can go to a specific line.
- Is there a value to look for that indicate the end of the file?
After you've loaded the list with ListN.ReadFile(), you can use ListX.Front(ID) for the first value or ListX.Back(ID) for the last value, or ListX.Get(ID, Index) to get a specific entry for a specified index number.

Btw, this post has a function attached that, if I understand you correctly, can be very helpful for coding this (since it's practically the same).

Happy coding. :)

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Line reading in a CSV file

Postby arjfca » 28 Apr 2012

Thanks John
As always, you are very pertinent.


Still a bit cloudy for me the concept, but I will get it...
Thanks for the link, will be helpful

Martin


Return to “MultiCharts”