|
Re: How to use dataFromCSV
[Re: anissyo]
#485950
05/14/22 13:40
05/14/22 13:40
|
Joined: Feb 2017
Posts: 1,806 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,806
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.
|
|
|
|