get data from excel file

I have two excel file. The first one is the main excel file that has two columns: one with all workers names and second column with their job. The second excel files has one column with some worker that has won a prize. I want a code that look at the main excel file and write a second column that has the jobs for those worker that won a price.
Note: if it is hard wo deal with xls file, I can move the information to txt file and work with txt file

2 Comments

Namo
Namo on 3 Mar 2011
worker name has diffrent length and contain different number of word (not just first and last name)
Namo
Namo on 3 Mar 2011
xlsread create cell data. How can we search for item in cell array?

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 3 Mar 2011

0 votes

See xlsread(), xlswrite() . With xlswrite() you can specify a particular cell range to write the data in to.
  1. xlsread to read both files into cell arrays.
  2. Use set operations (like, say, intersect) to find the names that are common to both.
  3. Use the corresponding indices to extract the jobs.
  4. Then use xlswrite to write the results.
Example of using intersect for this:
>> [names,idx] = intersect({'bob','sally','fred'},{'fred','sally'})
names =
'fred' 'sally'
idx =
3 2

Asked:

on 3 Mar 2011

Community Treasure Hunt

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

Start Hunting!