How can I index file information into information into a table?

1 view (last 30 days)
Sorry if the terminology is a little vague, but I'm looking to take data from a .csv file and read it into a table. I do not want to simply read the file though, I would like to index it into an array. For example, I would have a .csv that looks like:
*Product* *Price* *Order Quantity* Apples 1.29 15
Oranges 2.35 12
Potatoes 5.65 6
Apples 1.31 1
Berries .99 7
Oranges 2.30 5
Ideally, I would like to sort this information into a table that looks like this for the given example:
*Apples* *Oranges* *Berries* *Potatoes*
Row 1: 1.29 N/A N/A N/A
Row 2: 1.29 2.35 N/A N/A
Row 3: 1.29 2.35 N/A 5.65
Row 4: 1.31 2.35 N/A 5.65
Row 5: 1.31 2.35 .99 5.65
Row 6: 1.31 2.30 .99 5.65
I'd prefer to complete this without a for loop, ask the sample I'm using has about 400,000 data points.
Thanks
  3 Comments
Walter Roberson
Walter Roberson on 25 Jun 2015
I can see prices being reflected in the table, but it is a mystery as to which Row each should start on or how many rows the same price should extend to.
Mukul Rao
Mukul Rao on 26 Jun 2015
I agree, more information is needed. However, I would be inclined to use the categorical array feature in MATLAB. Please review the section "Select data based on categories" at the following link on converting table variables containing strings to categorical:

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!