open large csv file

조회 수: 4 (최근 30일)
asad ali
asad ali 2019년 8월 29일
댓글: Nicolas B. 2019년 8월 29일
i have a csv file with 93 coloums and 150000 rows
number of coloums may change to 90 in some tests and all entries are text / string
i need a single code to calculate the no of rows and couloums dynamically by reading the csv file and then get the 93/90 variable data in seprate variables
i have been using uiimport in my GUI but when i compiled the code into an application (.exe) using matlab application compiler uiimport function gives following error
"Error using uiimport>showLargeFileWindow (line 1126)
Java exception occurred:
java.lang.NullPointerException
at com.mathworks.mlwidgets.importtool.TextImportClient.showWaitProgressWindow(TextImportClient.java:253)"
Now i am using
fid=fopen('1.csv');
>> data = textscan(fid,'%s','HeaderLines',0,'Delimiter',',','CollectOutput',1);
now i am getting all the data in i single variable data Untitled.jpg
can any body help me for opening this csv file in standalone application with each variable having its values stored
First row are the variable names

답변 (1개)

Nicolas B.
Nicolas B. 2019년 8월 29일
Hi Asad,
have you considered using readcell or readtable depending of what you need for data type? You can configure it to define the delimiters. For example:
T = readtable(filename, 'Delimiter',';');
Regards
  댓글 수: 2
asad ali
asad ali 2019년 8월 29일
i am receiving this error while using readtable
Tbl = readtable('1.csv', 'delimiter', ';', 'headerlines', 0, 'readvariablenames', true);
Error using table/readTextFile (line 237)
Cannot interpret data in the file '1.csv'. Found 92 variable names but 93 data columns. You
may need to specify a different format string, delimiter, or number of header lines.
Error in table.readFromFile (line 33)
t = table.readTextFile(filename,otherArgs);
Error in readtable (line 118)
t = table.readFromFile(filename,varargin);
Nicolas B.
Nicolas B. 2019년 8월 29일
I would say that you have 1 header missing. Try to open your csv-file in libreoffice or excel and check whether there are headers to each column. If you cannot correct that, read the file without headers.

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

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by