# Access array using composite symbol name

**URL:** <https://discourse.processing.org/t/access-array-using-composite-symbol-name/41462>\
**Category:** Coding Questions\
**Created:** [March 26, 2023, 11:56pm UTC](https://discourse.processing.org/t/access-array-using-composite-symbol-name/41462 "2023-03-26T23:56:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmmmp](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jmmmp](https://discourse.processing.org/u/jmmmp)\
**Post date:** [March 26, 2023, 11:56pm UTC](https://discourse.processing.org/t/access-array-using-composite-symbol-name/41462/1 "2023-03-26T23:56:44Z")

</div>

Hello,

I have several arrays which are loaded from text files, e.g. array1 = loadStrings(“marker-energy-sc2.txt”); , then array2, array3, etc.  
I would need to access values in those arrays based on another value coming from a textfile with 1, 2, 3, …  
I was trying to connect the string “array” and the value to create “arrayX” to access any of the first mentioned array dinamically, but it seems that I can’t use a symbol name to access an array? In java “eval” could be used for it, but it isn’t available in processing.  
Is this technique possible with other means, or should I load all values into one hashmap or intdich, and structure the stringnames so that I can grab the values from there? E.g. array1-0, array1-1, etc.

best,

jmmmp

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [March 27, 2023, 12:04am UTC](https://discourse.processing.org/t/access-array-using-composite-symbol-name/41462/2 "2023-03-27T00:04:20Z")

</div>

> [@jmmmp](#):
>
> “marker-energy-sc2.txt”

If those files happen to be CSV or TSV:

> **[Comma-separated values](https://en.wikipedia.org/wiki/Comma-separated_values)**
>
> Comma-separated values (CSV) is a text file format that uses commas to separate values. A CSV file stores tabular data (numbers and text) in plain text, where each line of the file typically represents one data record. Each record consists of the same number of fields, and these are separated by commas in the CSV file. If the field delimiter itself may appear within a field, fields can be surrounded with quotation marks.
> The CSV file format is one type of delimiter-separated file format. Delimit...

You could use **loadTable()** instead:

> **[loadTable() / Reference](https://processing.org/reference/loadTable_.html)**
>
> Reads the contents of a file or URL and creates a Table object with its values. If a file is specified, it must be located in the sketch's "data" folder. The filename parameter can also be a URL to a …

Datatype Table offers many access & lookup methods:

> **[Table / Reference](https://processing.org/reference/Table.html)**
>
> Table objects store data with multiple rows and columns, much like in a traditional spreadsheet. Tables can be generated from scratch, dynamically, or using data from an existing file. Tables c…

---

<div class="post-metadata">

**Author:** ![jmmmp](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@jmmmp](https://discourse.processing.org/u/jmmmp)\
**Post date:** [March 28, 2023, 9:51am UTC](https://discourse.processing.org/t/access-array-using-composite-symbol-name/41462/3 "2023-03-28T09:51:29Z")

</div>

Thanks, that was a very good way of solving it.
