Is there a function available to import row vectors from csv file?
조회 수: 5 (최근 30일)
이전 댓글 표시
I have csv files where the data is row wise. so the vector names are in first column and data is along the row. Is there are function available to import the data in matlab. The row vector sometime can be characters or numeric data. Any help would be appreciated. Thanks
Now I have attached sample data file also
댓글 수: 0
답변 (3개)
Image Analyst
2017년 10월 9일
You forgot to attach the file. Failing that, all I can suggest is to try importdata() (which is pretty flexible in what it can understand), or textscan().
댓글 수: 0
Image Analyst
2017년 10월 10일
sampleData = importdata('sample.csv')
seems to work just fine. Any problem with it? If so, state what they are.
댓글 수: 2
Image Analyst
2017년 10월 11일
importdata has a 'headerlinesIn' option where you can tell it to skip 20 lines, if there is a known number of header lines in the image. However there is a problem that you have lines like
-1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
that follow the data, and that causes it to throw an error. You might have to write a custom function that either (1) reads your code with fgetl() and textscan() to parse and convert lines of text as you go down line-by-line, or (2) read the file line-by-ling and write only the "good" data lines to a file called 'delete_me.csv' which you can then read with importdata() and delete after it's read in and you don't need it anymore.
참고 항목
카테고리
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!