Removing spaces from text file on SD

Hi

I'm trying to find a way to remove spaces from text file located on SD card.
Example: if the file contains "hello hello hello hello", i want it to become "hellohellohellohello".
The text files are quite large, around 50000 characters each.
I am using the SD.h Library and i don't find a function that can help me with that.

Any suggestions?

Thanks.

You haven't provided near enough information. Are you trying to remove the spaces from a file that you created? If so, why did you put the spaces in there in the first place?

Do you want to read a record from one file, strip the spaces from that record, and write the result to another file?

One way is to copy the content to a new file character by character, discarding the characters you don't want, then move aside the original file and replace it with the new file.

Here's the full information:
The SD card contains a text file which i didn't create. I want to read the text file from the card, remove the spaces and keep the result on the same file.
Is it possible?

microsoft office word will do it for you if you can open it like that. Just use the replace tool, tell it to find the spaces and replace it with nothing. Just tried it and it works

robertcassar:
microsoft office word will do it for you if you can open it like that. Just use the replace tool, tell it to find the spaces and replace it with nothing. Just tried it and it works

Thanks for the answer, but i want the arduino to perform the task, without the need to load the file into a PC first.

What you want to do is read the file in, char by char and strip out the spaces as you read it in.

 webFile = SD.open("prices");
  if (webFile) {
    Serial.println("Reading prices....");

    char myChar;
    // read from the file until there's nothing else in it:
    while (webFile.available()) {
      myChar = webFile.read(); 
      if(myChar != " "){
       currentLine += myChar;
        }
        if (myChar == '\n') {
          //Write your code here to write the line to a new file.
          // you probably  want to write the new file to a new folder but that is up to you.
          }
          currentLine = "";
         
        } 
    }
    // close the file:
    webFile.close();
    Serial.println("SUCCESS - Loaded price file.");

Yonatan:
Hi

I'm trying to find a way to remove spaces from text file located on SD card.
Example: if the file contains "hello hello hello hello", i want it to become "hellohellohellohello".
The text files are quite large, around 50000 characters each.
I am using the SD.h Library and i don't find a function that can help me with that.

Any suggestions?

Thanks.

Doing the operation directly on a file in-place would require an SD library that
supports having a file open for read-write, supports seek() and you'd also need
to know the block size in order to avoid "stomping on your own feet".

[ no idea if such a library exists, BTW ]