简体   繁体   中英

Reading .csv file while it is being written

I have a similar problem to the one described here below in a different question: Reading from a CSV file while it is being written to

Unfortunately the solution is not explained.

I'd like to create a script that plots some variables in a .csv file dynamically. The .csv is updated everytime a sensor registers something. My basic idea was to read the file each fixed period of time and if the number of rows is increased, to update the plot with the new variables.

How can I proceed?

I am not that experienced in csv

but take this logic

def writeandRead(one_row):
  with open (path/file.csv,"a"): # it is append .. if  your case write just change from a to w  
    write.row(one_row)

  with open(whateve.csv,"r"):
    red=csv.read #i don't know syntax ... take the logic😊
  return red

for row in rows: #or you have a lists whatever dictionary 
 print(writeandRead(row))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM