| 查看: 592 | 回复: 6 | |||
| 【奖励】 本帖被评价2次,作者fspdlh增加金币 2 个 | |||
| 当前主题已经存档。 | |||
[资源]
【原创】一个自编的读取文本文件数据的函数
|
|||
|
如题,自编了一个函数,自已感觉用起来还是很方便的,如有需要可以下载。 可以读取整个文件,读取第N行,读取第M行到第N行,读取第M行到倒数第N行,读取第M次(也可以是最后一次、倒数第M次)出现字符串str的行开始(或结束)的数据,等等。 以下是自编的帮助文档。 %Get text from file % %Input paraments: % fid: filename or the indicater of the file % sea_tag: find the target text from the beginningning of the text or % the current position % 0: the beginningning of the file % 1: the current position % beg profix: paraments to point out the beginning of the output text % end profix: paraments to point out the endding of the output text % tag: target string, a string inclued in the target line % mode: the method to match the target line % 1: comletely matched % 2: beginning matched including blanks % 3: beginning matched ignoring blanks % 4: included % count: the Nth of the target line % offset: offset from the target line % negative ingeger: Nth line before from the target line % zero: the target line % positive integer: Nth line followed from the target line % %The number of input paraments: % 1 y=GetFileText( fid ) % 2 y=GetFileText( fid, offset ) % 3 y=GetFileText( fid, sea_tag, offset ) % 4 y=GetFileText( fid, sea_tag, beg_offset, end_offset ) % 6 y=GetLineText( fid, beg_sea_tag, % beg_str,beg_mode, beg_count, beg_offset ) % 7 y=GetFileText( fid, beg_sea_tag, beg_offset, % end_str, end_mode, end_count, end_offset ) % 7 y=GetFileText( fid, beg_sea_tag, % beg_str, beg_mode, beg_count, beg_offset, % end_offset ) % 10 y=GetFileText( fid, beg_sea_tag, % beg_str, beg_mode, beg_count, beg_offset, % end_str, end_mode, end_count, end_offset ) [ Last edited by sunxiao on 2009-3-8 at 13:11 ] |
» 猜你喜欢
综述论文作为代表作会不会影响评审专家的印象分?
已经有12人回复
2019年青年基金涵评意见,大家看看几个A,几个B?
已经有4人回复
应该是93bebmhtak前后十一个字符比较关键
已经有29人回复
奇怪,两个人的filecode固定段从头到尾一模一样
已经有9人回复
是这周出结果还是下周出结果?
已经有3人回复
小木虫上这么多卖论文的,真有人买论文么?感觉没必要啊
已经有9人回复
有时候,自然基金真的不能太认真 (我的申报经验)
已经有4人回复
帮忙看看fileCode
已经有13人回复
为什么网上很多人说本周 12号出结果
已经有7人回复
读博的好处
已经有3人回复
读取文件的例子
|
>> type a.txt 01 02 03 01 04 05 06 01 07 08 01 09 10 >> GetFileText('a.txt') ans = '01' '02' '03 01' '04' '05' '06 01' '07' '08 01' '09' '10' >> GetFileText('a.txt',4) ans = 04 >> GetFileText('a.txt',0,4,-2) ans = '04' '05' '06 01' '07' '08 01' '09' >> GetFileText('a.txt',0,'01',4,1,0) ans = 01 >> GetFileText('a.txt',0,'01',4,2,0) ans = 03 01 >> GetFileText('a.txt',0,'01',4,2,-1) ans = 02 >> GetFileText('a.txt',0,'01',4,2,1) ans = 04 >> GetFileText('a.txt',0,'01',4,-1,-2) ans = 06 01 >> GetFileText('a.txt',0,'01',4,-2,0) ans = 06 01 >> GetFileText('a.txt',0,'01',4,-2,0,-1) ans = '06 01' '07' '08 01' '09' '10' >> GetFileText('a.txt',0,'01',4,1,0,'01',4,-1,0) ans = '01' '02' '03 01' '04' '05' '06 01' '07' '08 01' >> GetFileText('a.txt',0,3,'01',4,3,0) ans = '03 01' '04' '05' '06 01' '07' '08 01' |
2楼2009-03-02 22:43:40
3楼2009-03-03 08:55:18
4楼2009-03-03 09:15:06
5楼2009-03-26 01:46:35
7楼2009-04-02 23:47:41
简单回复
dnp6楼
2009-03-26 14:37
回复










回复此楼

100