フィルターのクリア

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 Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by