how to read a text file including the end of line
7 views (last 30 days)
Show older comments
Hello,
I have a text file which is generated by a software. The software saves data from hexadecimal to ascii format. So in the text file, there are a lot of end of line ('\n') characters.
When I use fread or fgets, they will ignore these characters, which will cause data lost. How can I read the file without losing anything?
Thank you.
0 Comments
Answers (1)
Star Strider
on 11 Feb 2016
The fgetl function will remove the newline '\n' characters. Is that what you want to do?
3 Comments
Guillaume
on 11 Feb 2016
As walter said, the newline is still there:
data - fread(fid, N);
find(data == 10)
will show you the indices of all the newlines.
See Also
Categories
Find more on Low-Level File I/O 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!