how to read complicated CSV files into matlab?
显示 更早的评论
My raw CSV file looks like the 1st pic. And I wants to use Matlab read it into the format as the 2rd pic. I have over 1000 the same kind of CSV files, it will be painful if I do it by copy/paste. How can I do this? Any examples? thanks.
I am a new user here, do not know how to post images, Please click the links to see. Thanks!
-------------------------------- raw data:
ID
Height
1 2 3
4 5 6
Weight
1 2 3
4 5 6
---------------------------
output data:
id height weight
1 1 1
1 2 2
1 3 3
...
采纳的回答
更多回答(1 个)
Matt Kindig
2012-5-21
0 个投票
Can you excerpt the actual text of your CSV file (not the file imported into Excel that you screenshot, but the actual original file with the commas shown and everything)? I ask because I don't think you'll be able to simply use csvread/dlmread, but will need to use a more sophisticated approach using something like fscanf or regexp. Please post an excerpt of your file.
Also, where does the ID come from? Are there other fields marked 'id' later in the file (such as A002)? Note that the raw/output data shown in your posting and in the screenshots is inconsistent--this makes it a bit confusing for me.
类别
在 帮助中心 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!