MATLAB: How to import CSV files with text and numeric values csvMATLABtable SOLVED Best Answer How about using xlsread?[num,txt,raw] = xlsread('best.csv') ; Related SolutionsMATLAB: How to import a file that contains text and numerical values Lose the blanks in the format string--that's causing grief in trying to match them in the parsing...>> fid=fopen('ryan.txt','r');>> a=textscan(fid,'%d%d%d%d%s%s%s%d%d%s')a = Columns 1 through 7 [4x1 int32] [4x1 int32] [4x1 int32] [4x1 int32] {4x1 cell} {4x1 cell} {4x1 cell}Columns 8 through 10 [4x1 int32] [4x1 int32] {4x1 cell}>> a{1}ans = 1 3 4 2>> frewind(fid)>> b=textscan(fid,'%d%d%d%d%s%s%s%d%d%s','collectoutput',1)b = [4x4 int32] {4x3 cell} [4x2 int32] {4x1 cell}>> b{1}ans = 1 1 10230435 3 3 4 23423423 4 4 2 23433554 5 2 5 23434234 7>> fid=fclose(fid);BTW, why on earth would you name a text file with an ".m" extension??? MATLAB: Importing large amounts of text and numerical data from csv or txt files numcols = 1000;fmt = repmat('%f',1,numcols);fid = fopen('YourFile.csv', 'rt');indata = textscan(fid, fmt, 'Headerlines', 2, 'Delimiter', ',', 'TreatAsEmpty', 'NA', 'CollectOutput', 1);fclose(indata);indata = indata{1}; Related QuestionProblem by importing alpha numeric text filesImporting Matrix from text or csv filesHow to import this CSV fileImport text files with character and numeric data
Best Answer