Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/20/24 06:09
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
2 registered members (flink, Edgar_Herrera), 695 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
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