Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [SOLVED] ReadString from CSV

Author
Message
zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 12th Feb 2021 16:39 Edited at: 12th Feb 2021 16:41
Hello friends,

first, greetings to you all!

I have a simple question for you, maybe very amateurish.

Please. I have a CSV file with the individual lines:

kasava;12345;germany;789
jinonice;25645;germany;857
stuhlov;45789;germany;124

etc.

If I use:



Then in a$ I have the whole file.
But I need for further work to have in a$ individual lines.

So for example:
a$ [1] = "kasava;12345;germany;789"
a$ [2] = "jinonice;25645;germany;857"
a$ [3] = "stuhlov;45789;germany;124"

And I can't achieve that. Please does anyone know any simple example of how to do this?

Thank you very much in advance!
I am sorry for poor English

The author of this post has marked a post as an answer.

Go to answer

hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 12th Feb 2021 18:19
I believe ReadLine() looks for a line feed character to determine where the line ends, so make sure your file's lines are ending with line feeds and not just carriage returns.
zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 12th Feb 2021 19:07
ReadLine() can only read 1 line. I need to read all the rows, one by one.
I am sorry for poor English
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 12th Feb 2021 19:20
Sorry, I must have misunderstood your question. In that case, you'll want to use a string array to store your lines. Like this:

zxretrosoft
AGK Developer
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 12th Feb 2021 19:27
Yes, this is exactly it, thank you very much, my friend!
Thank you!

P.S. And I apologize for the bad English!

[Solved]
I am sorry for poor English
n00bstar
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 13th Feb 2021 12:43 Edited at: 13th Feb 2021 12:44
This post has been marked by the post author as the answer.
You might want to look into GetStringToken too.

Let's say you have 30 different characters and and their various stats in a csv file with Name,Class,HP,MP on each line that looks like this:

Bob,Warrior,30,30
John,Mage,10,50
Julie,Archer,20,20
[etc...]



Then this would print:
Bob
Warrior
30
30
John
Mage
10
50
Julie
Archer
20
20

etc etc...
-----------------------------------------------------------------------------
We all got a chicken duck woman thing waiting for us

Login to post a reply

Server time is: 2024-04-19 19:23:08
Your offset time is: 2024-04-19 19:23:08