- install the document monitor plugin, which checks every three seconds if a file has changed, and updates it if it has.
- it warns when a file has been closed, and gives the option to reload.
- it also has a manual option in the File menu Reload from Disk. You could add a shortcut Settings... -> Shortcut Mapper..., and make a keyboard shortcut for updating using some keys.
Can I see the contents of a csv file live while matlab is still working on it
9 次查看(过去 30 天)
显示 更早的评论
Hello,
My code is writing some data actively into a csv file. I would like to open the csv file and see what my matlab code writes into it live while the csv file is still open in excel and matlab is continuously writing data into it.
Is it possible, if yes how can I do it.
Thanks.
0 个评论
回答(3 个)
Stephen23
2017-5-14
1 个评论
Walter Roberson
2017-5-14
Note: how well this will work depends on exactly how the output is being written to the file. csvwrite() and dlmwrite() and xlswrite() might only update the file every 8 kilobytes or so.
If you are using fwrite() or fprintf() then some documentation hints that the output file will be flushed after every fwrite() or fprintf(), but this is not made explicit.
Jan
2017-5-14
The operating system is resonpsible for writing data to the disc. The bytes delivered by fwrite can be cached by Matlab, the OS and the hard disk also. See e.g. https://support.microsoft.com/en-us/help/324805/how-to-manually-turn-disk-write-caching-on-or-off and https://msdn.microsoft.com/en-us/library/windows/desktop/aa364218(v=vs.85).aspx. It matters if the file was opened by fopen in 'w' or 'W' mode.
On my system, the files are written in chunks of 1024 bytes, but I would not rely on this.
Conclusion: There is no reliable way to see the file's contents in real time. If you really need this feature, create a different strategy: Expand the function for writing the CSV file by a part, which copies the output to the display of an editor directly.
0 个评论
Ajit Dubey
2021-4-6
An easy fix for this is copy paste the file that is being written and you can open the copy file and see the current status...
It might be very late for this answer but it might be useful for anyone searching in future!!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!