3 registered members (frutza, Quad, AndrewAMD),
385
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
How to use dataFromCSV
#485937
05/13/22 13:13
05/13/22 13:13
|
Joined: Mar 2021
Posts: 42 Casablanca, Morocco
anissyo
OP
Newbie
|
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]
#485939
05/13/22 15:25
05/13/22 15:25
|
Joined: Mar 2021
Posts: 42 Casablanca, Morocco
anissyo
OP
Newbie
|
OP
Newbie
Joined: Mar 2021
Posts: 42
Casablanca, Morocco
|
I tried my friend i used this 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]
#485944
05/13/22 16:06
05/13/22 16:06
|
Joined: Mar 2021
Posts: 42 Casablanca, Morocco
anissyo
OP
Newbie
|
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]
#485946
05/13/22 16:27
05/13/22 16:27
|
Joined: Mar 2021
Posts: 42 Casablanca, Morocco
anissyo
OP
Newbie
|
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]
#485949
05/14/22 13:19
05/14/22 13:19
|
Joined: Mar 2021
Posts: 42 Casablanca, Morocco
anissyo
OP
Newbie
|
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.
|
|
|
Re: How to use dataFromCSV
[Re: anissyo]
#485950
05/14/22 13:40
05/14/22 13:40
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
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 ?? That's not a CSV (comma separated value) file, that's a SSV (semicolon separated value) file, a format that nobody uses. And there's no timestamp in the first column, which is required. So your first error is that your source material is no good. Fix that. Here's an example of a good CSV file, with a header line included (also supported by Zorro): Date,Value
2022/01/01,100.0
2022/01/02,101.0
2022/01/03,102.0
2022/01/04,103.0 Once you fix your source material, write the format string to match the format of your file. The manual spells this out very clearly, and there are examples in the example script.
|
|
|
Re: How to use dataFromCSV
[Re: anissyo]
#485951
05/14/22 13:57
05/14/22 13:57
|
Joined: Mar 2021
Posts: 42 Casablanca, Morocco
anissyo
OP
Newbie
|
OP
Newbie
Joined: Mar 2021
Posts: 42
Casablanca, Morocco
|
In the docs i found this in https://zorro-project.com/manual/en/data.htm : ss... - for an extended text field of size 4n-1, where n is the number of 's'. Occupies n adjacent fields in the dataset, while field 0 counts as 2 fields. since the dummy csv file contains only one line with "AAA;BBB;CCC" i told myself that the format should be "sss,sss,sss" here is my code :
function run()
{
LookBack = 100;
set(LOGFILE);
BarPeriod = 600;
string t=dataNew(1,9,9);
dataParse(1,"sss,sss,sss","History\\vvv.csv");
//print (TO_LOG,sftoa (t, 6));
}
but its not working i get this message error : Error 058: Bad file format for 'aaa;bbb;cc' in vvv.csv Error 111: Crash in run: run() at bar 35
Last edited by anissyo; 05/14/22 14:05.
|
|
|
Re: How to use dataFromCSV
[Re: anissyo]
#485953
05/14/22 15:08
05/14/22 15:08
|
Joined: Mar 2021
Posts: 42 Casablanca, Morocco
anissyo
OP
Newbie
|
OP
Newbie
Joined: Mar 2021
Posts: 42
Casablanca, Morocco
|
I am sorry the previous message was sent before I saw your last message here is what I did after reading your last response : I did replace the CSV file content with the sample you provided but nothing is solved
function run()
{
LookBack = 100;
set(LOGFILE);
BarPeriod = 600;
string t=dataNew(1,9,9);
dataParse(1,"+%Y/%m/%d,f","History\\vvv.csv");
}
but I still get this error message unfortunately : csvreader compiling........... Error 058: Bad file format for 'Date,Value' in vvv.csv Error 111: Crash in run: run() at bar 35
Last edited by anissyo; 05/14/22 15:10.
|
|
|
|