Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by 7th_zorro. 04/20/24 07:29
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, henrybane, flink, Edgar_Herrera), 758 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
dataFind() does not return the correct row for a timeperiod #470129
12/28/17 00:52
12/28/17 00:52
Joined: Nov 2017
Posts: 17
T
Tamas Offline OP
Newbie
Tamas  Offline OP
Newbie
T

Joined: Nov 2017
Posts: 17
Hi, I am having trouble retrieving the correct row for a timeperiod in a dataset.
I am using dataParse to read in a csv file and then trying to find the corresponding row for the bar's timeperiod. Here is the code:

to read and parse:

string Format = "%Y-%m-%d %H:%M:%S,f";
int RecordsEUR1H = dataParse(1,Format,InNameEUR1H);

and then:

int RowEUR1H = dataFind(1,wdate());

it returns the attached for this print:
printf("n Date: %s, Row: %i, Value: %f",strdate("%Y-%m-%d %H:%M:%S",wdate()),RowEUR1H, dataVar(1,RowEUR1H,1));


My CSV file looks like this:
2017-12-28 00:00:00,-3.2885940290891
2017-12-27 23:00:00,-3.2924455825864
2017-12-27 22:00:00,-3.217172985187
2017-12-27 21:00:00,-2.26513041276
2017-12-27 20:00:00,-2.24
2017-12-27 19:00:00,-2.2688089773
2017-12-27 18:00:00,-2.22088050314
2017-12-27 17:00:00,-2.21020870003
2017-12-27 16:00:00,-2.28022255943
2017-12-27 15:00:00,-2.24341123819
2017-12-27 14:00:00,-2.16543756146
2017-12-27 13:00:00,-2.15416666667
2017-12-27 12:00:00,-2.11968734734
2017-12-27 11:00:00,-2.1027027027
2017-12-27 10:00:00,-2.06518554688
2017-12-27 09:00:00,-1.87034035656
2017-12-27 08:00:00,-1.89573570759
2017-12-27 07:00:00,-2.0331478345
2017-12-27 06:00:00,-1.98296136309
2017-12-27 05:00:00,-1.97462293512
2017-12-27 04:00:00,-1.88625146886
2017-12-27 03:00:00,-1.90072752875
2017-12-27 02:00:00,-1.89032106867
2017-12-27 01:00:00,-1.89953051643
2017-12-27 00:00:00,-1.87954066089
2017-12-26 23:00:00,-1.90943396226

It looks as if dataFind returns a record for every 2nd or so timeperiod BEFORE the given date? How can i make sure that it return a record for the exact timeperiod? data for that timeperiod is available in the dataset as you can see.

thanks for the help in advance.
I am using Zorro S 1.72 but tried it on S 1.66 and it is the same.

Attached Files Untitled.jpg
Re: dataFind() does not return the correct row for a timeperiod [Re: Tamas] #470135
12/28/17 11:02
12/28/17 11:02
Joined: Nov 2017
Posts: 17
T
Tamas Offline OP
Newbie
Tamas  Offline OP
Newbie
T

Joined: Nov 2017
Posts: 17
I have shifted the wdate() value with 1 second to go over the hour and now it finds the correct value based on the time just 1 second before that. so I overcome the above issue, but still would be interested to find out why the exact match with datafind does not work.

Last edited by Tamas; 12/28/17 11:03.
Re: dataFind() does not return the correct row for a timeperiod [Re: Tamas] #470138
12/28/17 11:40
12/28/17 11:40
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
I assume that wdate() was not exactly on a hour boundary, but still, the 1 second shift should normally not be necessary. Can you contact support(at)opgroup.de with your script and the CSV file? They'll look into it, maybe the problem is caused by something else.

Re: dataFind() does not return the correct row for a timeperiod [Re: jcl] #470143
12/28/17 13:27
12/28/17 13:27
Joined: Nov 2017
Posts: 17
T
Tamas Offline OP
Newbie
Tamas  Offline OP
Newbie
T

Joined: Nov 2017
Posts: 17
thanks jcl, will drop them an email.
btw, how would you compare two DATE type variables to see if that are the same down to only the second? (no milliseconds or below)

Re: dataFind() does not return the correct row for a timeperiod [Re: Tamas] #470147
12/29/17 08:24
12/29/17 08:24
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
abs(Date1-Date2) < 1./(24*60*60)


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1