Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Sendatsu_Yoshimitsu · May 20, 2015 at 01:15 PM · c#arraystringparsing

Iterating through multidimensional arrays

I've been using http://wiki.unity3d.com/index.php?title=CSVReader to parse excel files that I've converted into CSV, the output that I end up with is a two-dimensional string array [y,x] such that with this input:

 A,1,!
 B,2,@

myArray[0,0] would be A, [0,1] would be 1, and [1,0] would be B. Once I have the 2d string grid, I want to go down the list vertically, and assign each row to a single-dimensional array textRow in some custom class:

 class myData {
 string[] textRow;
 }

The problem is, how do I programmatically articulate the concept of a row within the 2d grid? I won't know how many columns there are in advance, so I can't hard code it, but I'm not sure how to iterate across multiple dimensions.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image HTwist · May 20, 2015 at 01:22 PM 0
Share

If you aren't sure of the number of rows, why don't use List ins$$anonymous$$d?

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by HarshadK · May 20, 2015 at 01:31 PM

Something like:

 public TextAsset csvFile; 
 string[,] csvData; // This is your multidimensional array that stores the parsed CSV data.
 
 string[] textRow;
 
 void Start()
 {
     csvData = CSVReader.SplitCsvGrid(csvFile.text);
     textRow = new string[csvData.GetUpperBound(0) + 1];  // Instantiate the textRow array with the number of rows in csvData array.
     for(int i=0; i < textRow.Length; i++)
     {
         textRow[i] = csvData[i,0];
     }
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by 0V3RR1D3 · May 20, 2015 at 05:39 PM

 for(int x = 0 ; x < 100 ; x++){
 
    for(int Y = 0 ; Y < 100 ; Y++){
 
         //Acces the array like this
 
         array[x,y] = "pugs";
 
 
 
    }
 
 
 }


I Hope that makes sence, Where x < 100 and y < 100, That number would be the x and y length of the array

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sendatsu_Yoshimitsu · May 21, 2015 at 02:57 AM 0
Share

That helps a lot, thank you! :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

String Parsing 1 Answer

Converting a string to an int 2 Answers

Assigning String Value From Array in separate script sets value to null. 2 Answers

Array not displaying my level best time in my level select menu 0 Answers

how do i access string from another gameobject? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges