Gamestudio Links
Zorro Links
Newest Posts
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:48
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
3 registered members (Quad, VoroneTZ, 1 invisible), 648 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
dataParse Format in DATE #473039
06/11/18 04:34
06/11/18 04:34
Joined: Mar 2017
Posts: 65
G
Ger1 Offline OP
Junior Member
Ger1  Offline OP
Junior Member
G

Joined: Mar 2017
Posts: 65
I got a csv history file, where in column A the date/time of the timeseries is stored.

The format of column A is already stored in Windows DATE format (for example 10/01/2018 is stored as 43110). The problem I have is that I don't know what to put in for Format in dataParse.
I tried to use
string Format = "+f,f3,f1,f2,f4,f6,f5";
as according to the manual:

"The DATE format is equivalent to a double / var variable and counts the number of days since 12-31-1899 with a resolution of ~ 1 µsec."

However, this did not work at all (I double-checked using the dataSaveCSV script).

Can anyone advise on how to solve this?

Re: dataParse Format in DATE [Re: Ger1] #473041
06/11/18 07:30
06/11/18 07:30
Joined: Mar 2017
Posts: 65
G
Ger1 Offline OP
Junior Member
Ger1  Offline OP
Junior Member
G

Joined: Mar 2017
Posts: 65
By the way, I also tried converting column A from DATE into Unix format and use %t.

dataParse did not work with %t and neither did dataSaveCSV (I get an invalid parameter error).

So far the only way I got it working is by manually converting column A to DD/MM/YYYY and use
string Format = "+%d/%m/%Y,f3,f1,f2,f4,f6,f5";

Re: dataParse Format in DATE [Re: Ger1] #473044
06/11/18 08:11
06/11/18 08:11
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
dataParse supports %t. So the normal way would be to read all timestamps with %t, and then convert them by script from the Unix time format to the DATE format. You can use this formula:

Date = UnixSeconds/(24.*60.*60.) + 25569.;

Re: dataParse Format in DATE [Re: jcl] #473048
06/11/18 09:11
06/11/18 09:11
Joined: Mar 2017
Posts: 65
G
Ger1 Offline OP
Junior Member
Ger1  Offline OP
Junior Member
G

Joined: Mar 2017
Posts: 65
Thanks jcl.

Just tried it, %t works with dataParse, but dataSaveCSV still returns an invalid parameter error. I used below code:

int Records = dataParse(1,Format,InName);
dataSaveCSV (1,Format,"check.csv");

Also thanks a lot for your hint to converting from the Unix time format to the DATE format.

But could you please advise how that can be achieved?
Doesn't dataParse read from csv and convert to t6 directly?
I have no idea where to do the conversion from Unix to DATE.

Thanks

Re: dataParse Format in DATE [Re: Ger1] #473055
06/11/18 14:46
06/11/18 14:46
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
After parsing the data, run a loop over all records, read the date from field 0, convert it to DATE, and write it back. Then save the dataset. For saving in CSV format, use a normal date format string like "%Y-%m-%d", not "%t" which is specific to Zorro and not supported by the Windows date format.

Re: dataParse Format in DATE [Re: jcl] #473068
06/11/18 22:46
06/11/18 22:46
Joined: Mar 2017
Posts: 65
G
Ger1 Offline OP
Junior Member
Ger1  Offline OP
Junior Member
G

Joined: Mar 2017
Posts: 65
Thanks a lot.

Below code worked:

string Format = "+%t,f3,f1,f2,f4,f6,f5";

function main()
{
int Records = dataParse(1,Format,InName);
printf("n%d lines read",Records);
dataSort(1);
int i;
for(i=0; i<Records; i++)
dataSet(1,i,0,(dataVar(1,i,0) - 25569.)*(24.*60.*60.));

dataSaveCSV (1,"%d/%m/%Y,f3,f1,f2,f4,f6,f5","check.csv");
if(Records) dataSave(1,OutName);
}


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1