Gamestudio Links
Zorro Links
Newest Posts
C++ scripts
by AndrewAMD. 07/02/22 13:02
FXCM doesn't show up in Broker drop-down
by Smallz. 07/02/22 12:32
History & HistoryFolder
by DdlV. 07/01/22 14:57
car.c how to add a trailer or wagon?
by Ice2642. 07/01/22 13:35
IB: brokercommand to cancel **all** orders.
by AndrewAMD. 06/30/22 17:21
Save As dialog box (like file_select)
by jcl. 06/30/22 10:18
AUM Magazine
Latest Screens
DEAD TASTE
Tactics of World War I
Hecknex World
Scheherazade's Journey
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 446 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Anas, PeroPero, AlexTomb, BigW, QJSH
18790 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,481
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,481
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,481
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,481
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,481
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,481
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