필터 지우기
필터 지우기

How to use Comma delimiter for this .txt file. I have a file which looks like this. I have to separate them column wise with comma as delimiter. Urgent. Thanks in advance.

조회 수: 17 (최근 30일)
39.984702,116.318417,0,492,39744.1201851852,2008-10-23,02:53:04 39.984683,116.31845,0,492,39744.1202546296,2008-10-23,02:53:10 39.984686,116.318417,0,492,39744.1203125,2008-10-23,02:53:15 39.984688,116.318385,0,492,39744.1203703704,2008-10-23,02:53:20 39.984655,116.318263,0,492,39744.1204282407,2008-10-23,02:53:25

답변 (1개)

Jacob Halbrooks
Jacob Halbrooks 2014년 1월 30일
Assuming this text is in a file named mydata.txt and you want to read it into MATLAB, you can use TEXTSCAN. In the data, I see each row appears to have 5 numbers followed by a date and a time. In the format specifier then, I'd use %f to capture the numbers and %s for the dates and times. TEXTSCAN also allows you to define the delimiter:
fid = fopen('mydata.txt');
data = textscan(fid,'%f%f%f%f%f%s%s','Delimiter',',');
fclose(fid)
The "data" variable is now a cell array, with a cell for each column:
>> data{1}
ans =
39.9847
39.9847
39.9847
39.9847
39.9847

카테고리

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