Microsoft Excel uses (and sometimes abuses) temporary files to prevent your work from getting lost. Here is a quote from Microsoft Support:
When you save changes a Microsoft Excel file, the following occurs:
- The changed file is saved to a temporary file.
- The original file is deleted.
- The temporary file is renamed to the original file name.
The deleted original file is located in the same directory or folder as the newly modified file in Windows. On the Macintosh, temporary files are placed in an invisible folder called Temporary Items in the root level of the hard disk.
Temporary files should be automatically deleted when you close Excel, but, if you want to make sure of this, you could create a little script that deletes files in
/.TemporaryItems. Note that this folder is automatically excluded from spotlight searches because it is hidden.
My advice is to not use Excel. A .csv file is a simple text file so you could try other editors, depending on what your needs are. TextEdit, for example, only creates one temporary file located in the same folder as your file.
Since you updated your question and removed Excel out of the equation, I will add a few points.
If you are using an appropiate editor (TextEdit without auto-saving for example), there won't be any leftovers in the hard drive. Temporary/cached files were never created and the content of your text file was kept only in RAM while the file was open.
However, if this file is really important, you should consider other things besides "hard drive leftovers". If your system is compromised, it is not secure to open your file there. You should probably consider more "drastic" approaches like Sirex suggested in the comments.