- Joined
- Mar 2, 2014
- Messages
- 4,088
- Reaction score
- 2,680
- First Language
- Greek
- Primarily Uses
- RMMZ
This is kinda noobish question really.
Imagine we got a file at the same folder with the game.
Let's say we got a CSV file named ab.csv with a line on it being:
STR STR STR STR STR INT INT INT
text1, text2, text3, text4, text5, 9, 4, 1
Now imagine 500 lines like that.
I want to store them to an array (two dimensions) and get access to the data from there.
How can I import all the lines from a csv file to an array, and how can I have access to a specific value from a specific line?
I want to set variable 21 to 'text4'
$game_variables[21] = How do we refer to text4 value? Remember, not from the file. I want an array in RAM.
EDIT:
I am actually looking for a solution that will be executed through Eventing as a command or a bunch of commands. If that was PHP and not JS I would ask to put a CSV into a two dimension array that is symbolized like this: $DATA[j] in PHP but I don't know if it is similar in JS whatsoever. What I am asking is an equivalent command in JS that will run in MV and make such a data structure, drawing values from rows of a csv file.
EDIT 2:
Not sure if that would work in MV and how it would work:
stackoverflow.com
What I know so far is that if I have this in JS:
var items = [
[1, 2],
[3, 4],
[5, 6]
];
I can easily refer to the items as a two dimension array. Similar to other languages. Okay!
console.log(items[0][0]); // 1
console.log(items[0][1]); // 2
console.log(items[1][0]); // 3
console.log(items[1][1]); // 4
What is missing is the way to make the variable contain a csv row.
Imagine we got a file at the same folder with the game.
Let's say we got a CSV file named ab.csv with a line on it being:
STR STR STR STR STR INT INT INT
text1, text2, text3, text4, text5, 9, 4, 1
Now imagine 500 lines like that.
I want to store them to an array (two dimensions) and get access to the data from there.
How can I import all the lines from a csv file to an array, and how can I have access to a specific value from a specific line?
I want to set variable 21 to 'text4'
$game_variables[21] = How do we refer to text4 value? Remember, not from the file. I want an array in RAM.
EDIT:
I am actually looking for a solution that will be executed through Eventing as a command or a bunch of commands. If that was PHP and not JS I would ask to put a CSV into a two dimension array that is symbolized like this: $DATA[j] in PHP but I don't know if it is similar in JS whatsoever. What I am asking is an equivalent command in JS that will run in MV and make such a data structure, drawing values from rows of a csv file.
EDIT 2:
Not sure if that would work in MV and how it would work:

Converting a CSV File Into a 2D Array
How can i convert the data inside an CSV file to a 2d array? array[row][column] I already have an upload script that will display all the data inside a CSV file. Little snippet of my code, here'...
What I know so far is that if I have this in JS:
var items = [
[1, 2],
[3, 4],
[5, 6]
];
I can easily refer to the items as a two dimension array. Similar to other languages. Okay!
console.log(items[0][0]); // 1
console.log(items[0][1]); // 2
console.log(items[1][0]); // 3
console.log(items[1][1]); // 4
What is missing is the way to make the variable contain a csv row.
Last edited: