Saving a file in RAM
Posted: Thu Nov 21, 2019 5:00 pm
I am using a 4Gb pi 4 running Raspbian 10 Buster. I have two python3 programs running simultaneously with numpy imported as np. One periodically saves to the SD card a text file of data collected from a sensor and a second reads it periodically and displays the data it contains on the surface of a three-dimensional sphere.
I now need to speed up the process 100x or so. I need to move the file from the SD card to RAM. It is OK to lose it when I power down. It seems like a common problem, but when I search the forum using 'saving a file to RAM' or 'sharing a file without SD card' or several similar phrases, I come up with discussions of moving a file off the pi or having a slow upgrade.
How does one save a file to RAM instead of an SD card?
Code: Select all
Program A:
...
for k in range(sensors):
...
SN=S1[0,k,:,:]
filename="S1_ex4_b_src_"+str(k)+".csv"
np.savetext(filename,SN,fmt='%.7f',delimiter=',')
Program B:
...
for i in range(sensors):
filename="S1_ex4_b_src_"+str(i)+".csv"
curve=np.genfromtxt(filename,delimiter=",")
...
How does one save a file to RAM instead of an SD card?