get data from excel file
Show older comments
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
Answers (2)
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.
Matt Tearle
on 3 Mar 2011
- xlsread to read both files into cell arrays.
- Use set operations (like, say, intersect) to find the names that are common to both.
- Use the corresponding indices to extract the jobs.
- 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
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!