read csv file real time

조회 수: 10 (최근 30일)
Alissa
Alissa 2014년 6월 20일
댓글: Rupali Wagh 2019년 7월 15일
Is it possible to read a csv file in real time in matlab? ie as data is being written to the csv file, can matlab read it in real time? Thanks in advance! :)
  댓글 수: 1
Rupali Wagh
Rupali Wagh 2019년 7월 15일
hi i have same problem regarding real time csv , can u plase share the code the real time read csv .
thanks in advance!!!!

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2014년 6월 20일
It can be open by two apps, as long as the first app didn't put a lock on it. For example, open a csv file in notepad or wordpad, and you can still do whatever you want with it in some other app. Though the first app will have a "snapshot" of what it looked like when it read it in - it won't update "live" as the other app changes it. Some apps, such as MATLAB, will recognize when the file on disk has changed. For example open a text file in the editor and then in wordpad and change it and save it in wordpad. Then when you return to MATLAB, it will say the file has changed on disk and ask if you want to reload it.
I don't know if MATLAB's fopen() puts a lock on the files. You could easily check though.
  댓글 수: 2
Alissa
Alissa 2014년 6월 23일
Thank you for your answer! I am now using csvread in a while loop to read the file in real time. However, I am getting the error:
Error using dlmread
Mismatch between file and format string.
Trouble reading number from file (row 1415u, field 8u)
The code will read about 15 new lines of the csv file before giving this error. Would you possibly know what is causing this? Thanks!
Image Analyst
Image Analyst 2014년 6월 23일
Most likely every row does not have the same format. Look at line 15 and see how it differs from line 14.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by