Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 1,405 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to use dataParse to read csv file. #476097
01/26/19 12:49
01/26/19 12:49
Joined: Apr 2014
Posts: 24
yebit Offline OP
Newbie
yebit  Offline OP
Newbie

Joined: Apr 2014
Posts: 24
Hi, I'm working with a csv tick data file with the following field structure:

EUR/USD, 20160104 00:00:00.057, 1.08516, 1.08522

I'm not exactly sure the delimiter of the file (the commas are included for readability) but it opens in excel without any prompting. there are no headers.

the file is to be saved as a .t1 zorro file.

the code used to view the file data for verification is as follows:

string InName = "History\EURUSD-2016-01.csv";
string rowdate;
var rowprice, rowvar;
string Format = "ss,%t,%f,%f";
int Records = dataParse(1,Format,InName);
if (Records) {
printf("num records: %in", Records);
for (i = 0; i < 2; i++) {
printf("record #%i: n", i);
for (p = 0; p < 5; p++) {
rowdate = strdate("%Y-%m-%d", dataStr(1,i,p));
rowstr = dataStr(1,i,p);
rowvar = dataVar(1,i,p);

printf("tcolumn %i as...n", p);
printf("ttstringt: %sn", rowstr);
printf("ttdatet: %sn", rowdate);
printf("ttvart: %fn", rowvar);
printf("n");
}
}
}

the logfile printout:

num records: 5150327
record #0:
column 0 as...
string : ¶s
date : Invalid DateTime
var : 42373.000008

column 1 as...
string : EUR/USD
date : Invalid DateTime
var : 0.000000

column 2 as...
string : USD
date : Invalid DateTime
var : 0.000000

column 3 as...
string : (null)
date : NaD
var : 0.000000

column 4 as...
string : (null)
date : NaD
var : 0.000000

record #1:
column 0 as...
string : ¢0
date : Invalid DateTime
var : 42373.000010

column 1 as...
string : EUR/USD
date : Invalid DateTime
var : 0.000000

column 2 as...
string : USD
date : Invalid DateTime
var : 0.000000

column 3 as...
string : (null)
date : NaD
var : 0.000000

column 4 as...
string : (null)
date : NaD
var : 0.000000

variations around the format code produce no better results:
Format = "ss,%Y%m%d %H:%M:%S,,%f";
Format = "0,,%Y%m%d %H:%M:%S,,%f";
Format = ",,%Y%m%d %H:%M:%S,,%f";
Format = ",%Y%m%d %H:%M:%S,,%f";
Format = "ss,%Y%m%d %H:%M:%S,,%f";
Format = "ss,%Y%m%d %H:%M:%S,%f,%f";
Format = "0ss,%Y%m%d %H:%M:%S,%f,%f";
Format = "ss,%t,%f,%f";
Format = ",,%Y%m%d %H:%M:%S,%4f";
Format = "1ss,%Y%m%d %H:%M:%S,%4f";
Format = "1ss,%Y%m%d %H:%M:%S,%4f,%3f,%2f,%1f";
Format = "ss,%t,%3f";
Format = ",,%t,%3f";
Format = "%t,%3f";
Format = ",%Y%m%d,%3f";
Format = ",%Y%m%d %H:%M:%S,%f,%f";
Format = ",%Y%m%d %H:%M:%S,%2f";
Format = ",%Y,%2f";
Format = "ss,%Y%m%d %H:%M:%S,%2f,%3f";
Format = "ss,%t,%f,%f";
Format = "ss;%t;%f;%f";

any hints for getting zorro to correctly parse the csv file?

Re: how to use dataParse to read csv file. [Re: yebit] #477043
05/05/19 16:00
05/05/19 16:00
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline
Senior Member
Grat  Offline
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

try this

Code:
rowdate = strdate("%Y-%m-%d", dataStr(1,i,p));

-->

rowdate = strdate("%Y-%m-%d", dataVar(1,i,p));



Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1