Delete Records from text file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete Records from text file

Jump to solution
608 Views
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 Kudos
Reply
1 Solution
476 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
2 Replies
477 Views
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 Kudos
Reply
476 Views
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 Kudos
Reply