필터 지우기
필터 지우기

Can I see the contents of a csv file live while matlab is still working on it

조회 수: 13 (최근 30일)
Dubstep Dublin
Dubstep Dublin 2017년 5월 14일
답변: Ajit Dubey 2021년 4월 6일
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.

답변 (3개)

Stephen23
Stephen23 2017년 5월 14일
This is easy with Notepad++:
  1. install the document monitor plugin, which checks every three seconds if a file has changed, and updates it if it has.
  2. it warns when a file has been closed, and gives the option to reload.
  3. 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.
  댓글 수: 1
Walter Roberson
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
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.

Ajit Dubey
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!!

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by