Replacement of separation values / Save routine

Hello Everybody,

I have a simple question, which actually bothers me a little bit. :-)

I am using IGOR since a long time (>7y), but this simple problem I did not get fixed.

I would like to import a tab-separated text file and just want to replace the separation charcter from tab to a semicolon. In the LoadWave routine I can choose the separator...in the Save routine its not possible (I think).

This replacement will be done automatically (called from Windows) and is needed to fulfill the actual program. I hope somebody has a smooth and easy idea to perform this. Anything is ready...I just need this easy part performed by IGOR ;-)

Many thanks and best wishes
Raik

Raik,

Try the following code. It worked for my simple test. There is probably a better solution out there.

Jeff

Function ReplaceCharacter()
    String sLine
    String sMsg = "Select file to convert"
    String sOutputFile
    String sInputFile
    String sIdentifier = "_Converted"
    String sFileExtension
    String sFileName
    String sFilePath
   
    Variable vFileRef_Old       //input file handle
    Variable vFileRef_New       //output file handle
   
    Open /D /M=sMsg /R  vFileRef    //just getting info on file to open here, not actually opening yet
    if(strlen(S_fileName) == 0)
        return 0    //user canceled
    endif
   
    sInputFile = ParseFilePath(5, S_fileName, ":", 0, 0)        //convert path to mac style
    sFileExtension = ParseFilePath(4, sInputFile, ":", 0, 0)    //file extension
    sFilePath = ParseFilePath(1, sInputFile, ":", 1, 0)         //path without filename
    sFileName = ParseFilePath(3, sInputFile, ":", 0, 0)     //filename without extension
   
    sOutputFile = sFilePath + sFileName + sIdentifier + "." + sFileExtension    //destination file name + path
   
    Open /R  vFileRef_Old as sInputFile     //open the source ile for read only
    Open  vFileRef_New as sOutputFile       //create new destination file for output
   
    Do
        FReadLine vFileRef_Old, sLine //read one line terminated by CR, LF, CRLF or LFCR
        if(strlen(sLine) == 0)
            break   //end of file reached
        endif
        sLine = ReplaceString("\t", sLine, ";") //replace tabs with semicolons
        fprintf vFileRef_New,"%s\r\n",  sLine       //write modified line to new file
    While(1)
   
    Close vFileRef_Old      //close source file
    Close vFileRef_New      //close destination file
End
You might also try the wfprintf operation with a format like /F="%g;%g;%g\r\n" for example if writing three waves.