Why does Matlab turn values of 100 into 1 when importing from csv files?

조회 수: 3 (최근 30일)
lil brain
lil brain 2022년 12월 15일
편집: lil brain 2022년 12월 15일
Hi,
I use the following code to import data from csv files.
[file_list,path_n] = uigetfile('*.csv', 'Grab csv', 'Multiselect','on');
file_list = cellstr(file_list);
N = numel(file_list);
alldata = cell(1,N);
for ii = 1:N
G = fullfile(path_n,file_list{ii});
alldata{ii} = readcell(G, 'Delimiter',{',',';'}, 'ConsecutiveDelimitersRule','join');
end
However, when I go into the cell array alldata (see attached), I see that the values that were previously 100s are now 1s.
One of the many csv files I imported where this happens is 1411_task.csv which is the second cell in alldata (see attached). If I open the file in Notepad for example I can see that the values are actually "100". Any idea why that is the case and how I could fix it in my code?
Thank you!
  댓글 수: 10
lil brain
lil brain 2022년 12월 15일
Sorry for the confusion and thanks for the help @Voss @Torsten and @Jan!
Walter Roberson
Walter Roberson 2022년 12월 15일
I opened the file with BBEdit, which is a quite decent editor for Mac. The number 100 appears in only three places:
  • second column of line 5
  • second column of line 6
  • first column of a line in which 100 is the value of the first column
I also had my system display the file as a text file; those lines definitely end in ;1; not in 100.

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by