HOW CAN A .DAT FILE BE EDITED
Show older comments
Hi; I trying to change a certain number in a DAT file, the file consists of numbers and text as shown

The problem is every time I edit the file using commands like fprintf to overwrite the file, the external programme that supposes the read and executes the file gives me an error because it is not able to read the file anymore. please, is there a way to edit and save the file while it is still readable? Thanks
12 Comments
Stephen23
on 8 Jun 2017
"is there a way to edit and save the file while it is still readable"
Of course this is possible. However you did not give us any details of the file specifications, or what you tried so far, so how do you expect us to help you?
Ahmed Abed
on 8 Jun 2017
Edited: dpb
on 8 Jun 2017
dpb
on 8 Jun 2017
You can try
fileID = fopen('strain determination 01.DAT','wt');
if it has to do with what the external program expects for EOL marks.
What we really need is to see a copy of the actual text file itself that is successfully read, NOT how it's displayed.
Ahmed Abed
on 8 Jun 2017
Stephen23
on 9 Jun 2017
@Ahmed Abed: please edit your question and upload a copy of the file by clicking the paperclip button.
Ahmed Abed
on 9 Jun 2017
Ahmed Abed
on 9 Jun 2017
Stephen23
on 9 Jun 2017
Both zip and txt files are supported by this forum, so if you change the extension to .txt it should be able to be uploaded. What size is the file? Do you get an error or warning? What browser are you using?
Ahmed Abed
on 9 Jun 2017
As we see in this screenshot, you try to attach a .rar file. The error message tells clearly, that this is not supported, but a .zip file would work and .txt files also.
Nevertheless, your problem is solved and attaching the file is not needed anymore.
Instead of using 'wt' in fopen, you can replace the line breaks also by '\r\n'. Beside the Editor shipped with Windows, your application seems to require the DOS linebreaks. What a pitty.
Ahmed Abed
on 9 Jun 2017
Answers (0)
Categories
Find more on Search Path in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!