Ways to read large (>12Kb) text files from SD card
#1
Posted 24 August 2012 - 02:02 PM
#2
Posted 24 August 2012 - 02:34 PM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#3
Posted 24 August 2012 - 02:37 PM
#4
Posted 24 August 2012 - 02:52 PM
It all depends on the file format. Since you're writing daily stats? You could do several things:If I don't do the readtoend method, the process will be very slow and it will cause exception from my interrupt (8 pulse inputs).
Do you have any codes on how to do file seek? Maybe, I can use your method, but need to call the read file many times using the seek method to remember where I left off on the previous call.
- Make records an X amount of bytes large
- Create a file format that works with data blocks
- Create an index
I have too little information right now to really be able to help you out.
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#5
Posted 24 August 2012 - 05:10 PM
Just like to check anyone out there has a better idea how to handle large text file data log files?
What are you doing with the file once you have read it?
Regards,
Mark
To be or not to be = 0xFF
Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life
Follow @nevynuk on Twitter
#6
Posted 25 August 2012 - 12:29 AM
What are you doing with the file once you have read it?
Regards,
Mark
Hi Mark,
These data files (daily) are records of the engine consumption that sample every 1 mins.
Currently the record format is as follows: [mins since today's 00:00] | [Double variable with 3 decimal places]
Regards,
Alex
#7
Posted 25 August 2012 - 12:36 AM
Hi Stefan,It all depends on the file format. Since you're writing daily stats? You could do several things:
- Make records an X amount of bytes large
- Create a file format that works with data blocks
- Create an index
I have too little information right now to really be able to help you out.
That's sound like a good idea. Since each records is fit by the format [mins since 00:00 of the day] | [Double value with 3 decimal place]. I can fix string format for both. And use ReadBlock to do it. However, need to do some testing to see whether it improve in processing.
in fact, currently when I read back the full content, I will then pass the full file content (as string) back to the caller for further parsing and then determine the require range (report time start to end) and accumulate the total value in the field (2) - Double.
Regards,
Alex
#8
Posted 25 August 2012 - 07:24 AM
Maybe you should pass the filestream resource instead.in fact, currently when I read back the full content, I will then pass the full file content (as string) back to the caller for further parsing and then determine the require range (report time start to end) and accumulate the total value in the field (2) - Double.
I know it's tempting to read the full file and process that. It's the simplest way most of the time. But it's asking for memory issues. On a PC with 8GB RAM it's not such a big deal with text files, but imagine doing the same with a 1080p video file. Luckely video containers also work with blocks of data, for this particular reason.
When you know every day it writes 100 bytes, you know that day 4 starts after 300 bytes. Reading 100 bytes from 300 is very fast. I would go for that approach.
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users