How to read/import specific range of data from text files or spread sheets?
1 次查看(过去 30 天)
显示 更早的评论
Hi ALL, I have text files - user_info.txt and spreadsheet - movie_info.xls (can be text file if it would be easier to do). I need to read specific string - movie_ID from from user_info.txt, find that string in movie_info.xls and read/import whole line. The user_info document is structured as follow: userID \t movie_ID \t rating \n and the movie_info.xls as movie_ID \t description1 \t description2 \t ... \n So I need to find position of movie_ID in user_info document, read the string, find its position in movie_info.xls and read whole line. I know only the user_ID and length of movie_ID. Each user has multiple entries. I tried to user strfind function but it returns only starting poistion. I also don't know how to read from text file from some position to a delimiter. Fileread doesn't have the delimiter value and importdata works only for ASCII files. Please give me some ideas. Thank you.
1 个评论
Geoff Hayes
2015-1-19
Chisca - perhaps post some of your code to give us an idea of what you have tried, and then we can provide some guidance on how to continue. Are you reading all of the data in at once, or are you trying to just look for specific entries within the files?
I suggest that you try the former (use importdata, or textscan, or xlsread depending upon the file type) and then look in the first set of data (user info) for all rows whose first column corresponds to the known user id (you could sort this data beforehand). Then look in the second set of data (the movie info) and find all the movie information corresponding to the movies that match to the user.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!