Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 972 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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