Reading .csv with dlmread? (I'm doing something wrong)

조회 수: 19 (최근 30일)
Emanuele Joy
Emanuele Joy 2018년 5월 24일
댓글: Emanuele Joy 2018년 5월 24일
I'm trying to read this CSV file, attached below. I tried:
x = dlmread('tse2001to2020.csv',',',2,1)
Because I'm trying to skip the header, but it gives me this error message:
Error using dlmread (line 147)
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number
1, field number 3) ==>
/4/2002,12,4,2002,07:32:16,142,Total,1.024,2:04:00 AM\n
Error in HW7Prob3 (line 1)
x = dlmread('tse2001to2020.csv',',',
What am I missing here?

채택된 답변

Image Analyst
Image Analyst 2018년 5월 24일
It won't work because you have strings in the lines. You can use readtable() though:
filename = 'tse2001to2020.csv';
t = readtable(filename)
  댓글 수: 4
Image Analyst
Image Analyst 2018년 5월 24일
I think you can but you're have to call it at least twice - basically send in row and column inputs but avoid the string column, where the string it 'Total'.
By the way, you're supposed to tag homework as homework so no one gives you the solution directly, which could get you in trouble if you turned in that solution as your own work. I've added the tag for you to help you avoid that problem.
Emanuele Joy
Emanuele Joy 2018년 5월 24일
Oh, sorry! Wasn't aware of that. I'll do that next time. Thanks for all the help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile 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!

Translated by