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 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,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
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: 42
Casablanca, Morocco
anissyo Offline OP
Newbie
anissyo  Offline 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 :

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,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,725
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: 42
Casablanca, Morocco
anissyo Offline OP
Newbie
anissyo  Offline 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

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,725
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

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