Delete Records from text file

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Delete Records from text file

ソリューションへジャンプ
997件の閲覧回数
utsavikalpesh
Contributor V

Hi,

I am working with Codewarrior v10.6 and of MQX v4.0.

I have create a .txt in SDCard. And I am writing a numbers of Record into .txt file. I also have put the limits to write say only 10000 records into .txt and if 10001 record comes then I need to delete the first record.

I have done this manually by read , shift and copy logic.But I dont want to write that code stuffs in my project due to limit of RAM and CPU time, instead want simple function in mfs library that make it happen.

So is there any inbuilt function or any another simple idea that can remove the records from text file??

Please help me.

0 件の賞賛
返信
1 解決策
865件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hi,

Unfortunately there isn’t any “simply” way, how to do it according your expectation.

I would like to recommend use “log rotate” technique:

Create one file and fill it by e.g. 10000 records. After that you should create new file and fill it by another 10000 records. In case of new record (20001), you can rewrite oldest file (delete oldest file and create new)…

This allows you to keep at least 10000 records in two files without any specific resource overhead.

Of course, this technique could be much more flexible. In typical case: we create log file every day (second/minute/hour/week) and files older than one weak are deleted.

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
866件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hi,

Unfortunately there isn’t any “simply” way, how to do it according your expectation.

I would like to recommend use “log rotate” technique:

Create one file and fill it by e.g. 10000 records. After that you should create new file and fill it by another 10000 records. In case of new record (20001), you can rewrite oldest file (delete oldest file and create new)…

This allows you to keep at least 10000 records in two files without any specific resource overhead.

Of course, this technique could be much more flexible. In typical case: we create log file every day (second/minute/hour/week) and files older than one weak are deleted.

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信
865件の閲覧回数
utsavikalpesh
Contributor V

Hi Radek,

Thanks for giving me information.

Regards,

Utsavi Bharchwala

On Tue, May 12, 2015 at 4:17 PM, RadekS <admin@community.freescale.com>

0 件の賞賛
返信