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
1 registered members (SBGuy), 652 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
How to use dataFromCSV #485937
05/13/22 13:13
05/13/22 13:13
Joined: Mar 2021
Posts: 42
Casablanca, Morocco
anissyo Offline OP
Newbie
anissyo  Offline OP
Newbie

Joined: Mar 2021
Posts: 42
Casablanca, Morocco
Hello guys,

I need to use this function to read some CSV file, I am unable to figure out how this function works

dataFromCSV (int Handle, string Format, string Filename, int Column, int Offset)

what I don't understand is the Handle, the Format and Offeset.

cheers,

Re: How to use dataFromCSV [Re: anissyo] #485938
05/13/22 13:49
05/13/22 13:49
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
The dataset function arguments (Handle, Format, and Offset) are described near the bottom of the manual page:
https://zorro-project.com/manual/en/data.htm

Re: How to use dataFromCSV [Re: anissyo] #485939
05/13/22 15:25
05/13/22 15:25
Joined: Mar 2021
Posts: 42
Casablanca, Morocco
anissyo Offline OP
Newbie
anissyo  Offline OP
Newbie

Joined: Mar 2021
Posts: 42
Casablanca, Morocco
I tried my friend i used this code :


Code
#include <contract.c>
function run()

{

LookBack = 100;
set(LOGFILE);
BarPeriod = 600;
set(PLOTNOW);


int column = dataFromCSV (1,"CSV", "aaa", 1, 1);

print (TO_LOG,column);
}



all I get is : Error 058: Bad code 'C' for '2, "1.7 Cub' in aaa.csv

PS: I have the CSV file in the history folder

Re: How to use dataFromCSV [Re: anissyo] #485941
05/13/22 15:42
05/13/22 15:42
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
"CSV" isn't a string format and "aaa" isn't a file name. Please read the link again that Andrew has provided.

When you still receive a 058 message after fixing this then have a look at the error message section.

https://zorro-project.com/manual/en/errors.htm

Re: How to use dataFromCSV [Re: anissyo] #485942
05/13/22 15:52
05/13/22 15:52
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Also, definitely check out the CSVtoHistory script included with Zorro for some excellent sample code.

Not all CSVs are made the same, so you will need to edit the CSV format to suit. See, you have different kinds of time stamps and field values to work with. Plus the sort order can be backwards.

Re: How to use dataFromCSV [Re: anissyo] #485944
05/13/22 16:06
05/13/22 16:06
Joined: Mar 2021
Posts: 42
Casablanca, Morocco
anissyo Offline OP
Newbie
anissyo  Offline OP
Newbie

Joined: Mar 2021
Posts: 42
Casablanca, Morocco
Hello guys, thanks for the replies, really appreciate it

this CSV file contains some breakouts that I detected using a python script, I want to take those break out and add them as signals in my zorro script so the format is irrelevant I guess since the format of the column is as follow: "YYYY/MM/DD strong up" or "YYYY/MM/DD medium up" or "YYYY/MM/DD weak down" etc. I just want to get the values from the CSV, regardless of what format is being used.

By the way Andrew I use occasionally CSVtoHistory to convert my data to T format, and I don't see datafromCSV used in the script...

Last edited by anissyo; 05/13/22 16:13.
Re: How to use dataFromCSV [Re: anissyo] #485945
05/13/22 16:19
05/13/22 16:19
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
What are you trying to do with the CSV, exactly?

Re: How to use dataFromCSV [Re: anissyo] #485946
05/13/22 16:27
05/13/22 16:27
Joined: Mar 2021
Posts: 42
Casablanca, Morocco
anissyo Offline OP
Newbie
anissyo  Offline OP
Newbie

Joined: Mar 2021
Posts: 42
Casablanca, Morocco
I want to extract the data from that CSV, every cell contains a date followed by "strong up" or "medium down" etc. but the format is as follows: "YYYY/MM/DD strong up"
every cell contains values extracted from an end-of-day candles break-out detector that I coded in python.

and I will write a c lite script to check if I am on a break-out day and then try some intraday strategies to see the result, how to get the CSV values? lol

Last edited by anissyo; 05/13/22 16:29.
Re: How to use dataFromCSV [Re: anissyo] #485948
05/14/22 06:58
05/14/22 06:58
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
First convert your data to CSV. You only need a comma after the date, a simple find/replace should do.

Then read the CSV with dataParse.

Re: How to use dataFromCSV [Re: anissyo] #485949
05/14/22 13:19
05/14/22 13:19
Joined: Mar 2021
Posts: 42
Casablanca, Morocco
anissyo Offline OP
Newbie
anissyo  Offline OP
Newbie

Joined: Mar 2021
Posts: 42
Casablanca, Morocco
ok i will try, i found this line here in an example in documentation : int Records = dataParse(1,Format,"History\\BTCEUR.csv");

the only thing I am not understanding is the Format argument, what should I do in Format in my case ?? Let's say for example that the CSV contains one line: "AAA;BBB;CCC" how to get this value from within the CSV ?? what format should I use ??

Thanks a lot my friend =)

Last edited by anissyo; 05/14/22 13:25.
Page 1 of 2 1 2

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