Copying data between two txt files

Hello

Im trying to figure out what the best way to move some data between two txt files on an SD card is.
I have 2 files, "send" and "archive" What im trying to do is move the data from send to archive.

Whats the best way of doing this?

Thanks in advance

Whats the best way of doing this?

Read from one file. Write to the other file. Is there even another way?

But you can only have one file open at a time?

But you can only have one file open at a time?

Why do you think that?

Each one that is open needs a 512 byte buffer, which may use up all (or more) of your memory.

You could open a file, position the cursor, read a record, close the file, open the other file, append the data, and close the file, until the first file had been copied.

H4rdstyler:
Im trying to figure out what the best way to move some data between two txt files on an SD card is.
I have 2 files, "send" and "archive" What im trying to do is move the data from send to archive.

Whats the best way of doing this?

That's a very vague description of what you want to do.

Your description could either mean:

  • delete "archive" file
  • rename "send" file to "archive"

Or the meaning could be:

  • open "archive" for appending data
  • read data from "send" and append to "archive"
  • when ready, delete "send"

You can have open more than one file at a time. But each file opened will cost you 512 bytes (or a bit more) of dynamic dynamically allocated SRAM, so most likely you need an MEGA2560 to have enough SRAM to do so.

There is no dynamic RAM on the Arduino.

aarg:
There is no dynamic RAM on the Arduino.

Sorry, English is not my mother language.

"Dynamically allocated RAM" might be the correct term for what I wanted to express?

PaulS:
Why do you think that?

Because all the examples says so, I assume thats wrong.

PaulS:
Each one that is open needs a 512 byte buffer, which may use up all (or more) of your memory.

You could open a file, position the cursor, read a record, close the file, open the other file, append the data, and close the file, until the first file had been copied.

Thats what im wondering, where do i "copy" and/or temporarily store the data after closing the send file? I know using a string isnt very effecient, allthou the data amounts are small (roughly 50 bytes) per line.

jurs:
That's a very vague description of what you want to do.

Its a very simple question, no need to elaborate in extreme details.

I know using a string isnt very effecient

Wrong. It is using a String that is not efficient.

Post #3 gives you a blueprint and you can debate it until the cows get home, but doing so means the net work accomplished is zero. Write it up as stated there and see what happens. If those "other sources" are correct, it won't work. If they are wrong, it will work and your problem's solved. Give it a try.