How to import a csv file in matlab 2015b

1 view (last 30 days)
kirthiga E
kirthiga E on 21 Dec 2018
Edited: Image Analyst on 22 Dec 2018
The file contains both numeric and text data.
  3 Comments
kirthiga E
kirthiga E on 21 Dec 2018
i need to import aqi data in MATLAB pls suggest me the comment im new to matlab
madhan ravi
madhan ravi on 21 Dec 2018
Kirthiga E's answer here since it was a comment:
My data

Sign in to comment.

Answers (1)

madhan ravi
madhan ravi on 21 Dec 2018
Edited: madhan ravi on 21 Dec 2018
fid=fopen('AQI Data.csv');
f=textscan(fid,'%s','delimiter','\n');
fclose(fid);
celldisp(f)
  7 Comments
Kirthi ga
Kirthi ga on 22 Dec 2018
fid = fopen('C:\Users\402\Desktop\AQI Data.csv')
fid =
3
T = readtable('C:\Users\402\Desktop\AQI Data.csv')
Error using readtable (line 135)
Reading failed at line 118. All lines of a text file must have the same number of delimiters.
Line 118 has 9 delimiters, while preceding lines have 8
Image Analyst
Image Analyst on 22 Dec 2018
Edited: Image Analyst on 22 Dec 2018
So are you going to fix your corrupt data manually, or do you want to write a MATLAB program to process each line one at a time and try to determine if there is a problem with each line? Then, if there is a problem with a line, like 118, what do you want to do? Just skip it? Or warn the user and give them what they have so far, or throw an error and return nothing? Please answer.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!