Delete Records from text file

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Delete Records from text file

跳至解决方案
998 次查看
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 解答
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 项奖励
回复
2 回复数
867 次查看
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 项奖励
回复
866 次查看
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 项奖励
回复