Gamestudio Links
Zorro Links
Newest Posts
Links dont work
by HamzaAhmed. 05/19/22 08:07
Unable to make new structures
by vinitrinh. 05/19/22 06:04
C++ scripts
by AndrewAMD. 05/18/22 16:43
Help with sorting data array
by degenerate_762. 05/18/22 12:24
How to use dataFromCSV
by AndrewAMD. 05/16/22 16:43
MT4, handling requote issues
by Grant. 05/15/22 00:04
Lapsa's very own thread
by Lapsa. 05/14/22 22:59
AUM Magazine
Latest Screens
DEAD TASTE
Tactics of World War I
Hecknex World
Scheherazade's Journey
Who's Online Now
8 registered members (HamzaAhmed, Grant, degenerate_762, vinitrinh, Quad, 3run, alibaba, Petra), 176 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Abdou, quandr, SGB1962, QuadraQuant, IcairDap
18781 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: How to use dataFromCSV [Re: anissyo] #485950
05/14/22 13:40
05/14/22 13:40
Joined: Feb 2017
Posts: 1,440
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,440
Chicago
Originally Posted by anissyo
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):
Code
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: 32
Casablanca, Morocco
anissyo Offline OP
Newbie
anissyo  Offline OP
Newbie

Joined: Mar 2021
Posts: 32
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 :

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 :
Quote

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] #485952
05/14/22 14:31
05/14/22 14:31
Joined: Feb 2017
Posts: 1,440
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,440
Chicago
Why didn't you change the source CSV file yet like I suggested? Do it. I don't understand why you continue to work with this bad file.

Re: How to use dataFromCSV [Re: anissyo] #485953
05/14/22 15:08
05/14/22 15:08
Joined: Mar 2021
Posts: 32
Casablanca, Morocco
anissyo Offline OP
Newbie
anissyo  Offline OP
Newbie

Joined: Mar 2021
Posts: 32
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

Code
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 :
Quote

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.
Re: How to use dataFromCSV [Re: anissyo] #485959
05/16/22 16:43
05/16/22 16:43
Joined: Feb 2017
Posts: 1,440
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,440
Chicago
It looks like the parser tried to read the header line for some reason. The default is one line, but try manually setting it to 1 using the Format string field.

Page 2 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