필터 지우기
필터 지우기

Different File locations: multiple delimiters in text files.

조회 수: 3 (최근 30일)
Philip Hoskinson
Philip Hoskinson 2016년 3월 17일
편집: Philip Hoskinson 2016년 3월 17일
I have a text files in different folders that are formatted as follows:
[ [num , num], [ num, num].... ]
First, I tried to pull in fullfiles into a structure array, then grab the names, and use the names and paths to read in the files into a cell array.
The brackets are confusing my current code:
temp = dlmread(fullfile(folderPath{k},tempN{i}),',')
How can I call files from different locations, to then open and use with textscan? Another way?
I tried: ( Doesn't work) The issue is calling the file properly I think:
file = fopen(fullfile(folderPath{k},fileNames{i}),'r');
temp = textscan(file,'%d''MultipleDelimsAsOne',1,'Delimiter',{',''['']'})
fclose(file);
temp is empty.... wrong formatspec, not reading file in properly?

답변 (1개)

Chad Greene
Chad Greene 2016년 3월 17일
You can use textscan instead of dlmread and specify any delimiter(s) you wish.
  댓글 수: 1
Philip Hoskinson
Philip Hoskinson 2016년 3월 17일
Issue is calling the file properly- I can't just use:
textscan(filename..)
Because the files are in different directories than the matlab code. I attempted to use fopen(fullpathandName) - but that is improper.

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

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by