Duplicate file name when using textscan
조회 수: 1 (최근 30일)
이전 댓글 표시
Hey, I've got a for loop set up reading files ending .txt it runs fine and does everything i want however it also pops up with duplicates of the file names with "._" before them and no data heres a picture of what i mean.
From row 10 is the data i want however rows 1-9 are just duplicate filenames and empty cells i don't want. Any reason for this? cheers Ollie
댓글 수: 0
답변 (1개)
dpb
2017년 3월 13일
There's always a reason, yes... :)
However, we can't tell what that reason might be for certain but the crystal seems fairly clear this morning and it says a likely possibility is that the file exists and is empty owing to a previous coding error have created the file but never wrote anything into it. A likely cause of having created the file would be having coded a loop trying to automate the creation of an output file based on the input file base name but with an extension and the logic in that loop, while not failing to run, created a name of the above pattern which looks like the original name with the two characters "._" having been prepended.
This could easily have occurred if there were an error in the input in building the intended filename that ended up with an empty string that was supposed to have been tacked onto the front of the name.
The solution I would guess would be to simply
delete '._Af*.txt'
to clean up the directory listing of the empty files. Of course, do some double-checking to make sure the above doesn't inadvertently include a file you do want first; use the pattern in dir and inspect the results first or similar.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!