【发布时间】:2017-06-24 07:28:41
【问题描述】:
我有一个如下所示的 python 脚本:
#!/usr/bin/env python3
import tables as pt
import numpy as np
import time
class TestTable(pt.IsDescription):
timestamp = pt.Float64Col()
voltage = pt.Float32Col()
h5file = pt.open_file('does_it_update_dropbox.h5', mode='a')
if not h5file.__contains__('/test'):
h5file.create_table('/', 'test', TestTable)
row = h5file.root.test.row
try:
while True:
time.sleep(10)
for _ in range(1000):
row['timestamp'] = time.time()
row['voltage'] = np.random.random(1)[0]
row.append()
h5file.root.test.flush()
print('1000 records added')
except:
pass
h5file.close()
每隔 10 秒,它会将数据写入 HDF5 文件。假设我在实验室里有一台计算机,它在一夜之间从传感器收集数据,我想从 5 英里外的家中分析这些数据。事实证明,如果这是在 Dropbox 监视的文件夹中,Dropbox 只会在脚本完成后同步(例如,如果我给它一个键盘中断)。我发现如果我在 Unix 机器上运行 touch does_it_update_dropbox.h5,我可以让 Dropbox 同步。但是,我实验室的机器是 Windows。
堆栈溢出,当 HDF5 文件写入 Windows 计算机时,如何通过 Dropbox 进行同步?
【问题讨论】:
-
如果您只需要对 Windows 进行“触摸”,请查看此 stackoverflow.com/questions/30011267/… 或编写一个小的 Python 脚本,如
open("does_it_update_dropbox.h5", "ab").write("")
标签: python dropbox hdf5 pytables