Reading data from csv or tsv file starting from some line
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi All,
I need to read data from a file openable in notepad. The file format can be csv or tsv. But the data will start from some line say 3 or 4.
Similar file has been attached. In this file the values are starting from line 5 and format is tsv. So line 5 will be read first and there will be five values which should be stored in a matrix and then line 6 values and so on.
I have tried too many ways but nothing is working.
Thanks all
댓글 수: 0
채택된 답변
Cris LaPierre
2020년 6월 9일
Is the format of your data the same in all your files? If yes, then use the import tool. This will allow you to interactively configure your import. You can then generate the corresponding code (as a script or a function) that can be used to automate the import process of all files with the same formatting.
If you do want to create an importing function, this video shows you how to generate and reuse your code.
And if you have a lot of files, this video shows you how to use the import function you have created in conjunction with a datastore to import multiple files.
댓글 수: 7
Cris LaPierre
2020년 6월 11일
I'm not aware of a simple, automatic way to do this. You can search MATLAB Answers for other posts on automatically detecting the number of headerlines, but each solution is typically tailored to the use case.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 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!