Can I overwrite a file without formatting it first?
Posted: Wed Apr 12, 2017 6:36 am
Hi,
I am generating a data table from a simulation. It is a table where line = sections in the neuron; and columns = times where an AP was recorded in each section (there is an APCount in each section). Eventually, I want each column of the file to represent the propagation of one AP through the neuron. APs do not overlap in time (the 1st is finished when the 2nd starts, etc.) so I guess it should be possible.
Problem is, as all APs do not propagate through the whole neuron, all lines do not get filled in at each iteration of the loop going through the sections. Thus, a shift appears in the columns, and columns may contain times belonging to the previous/next AP (not anymore one column = one AP). As I said, I want each AP to have its own column.
The solution I thought about was to first initialize a big table with values eg. 9999 (I'll be looking for the minimum of each column, hence the big number so it does not interfere). I'm first initializing the table (this works fine), then closing it. I want to re-open it and write over some of the 9999s. Now the issue is that NEURON formats the whole file if I try re-writing in it. The culprit seems to be wopen(): it is erasing the whole file each time it is called. However, if I don't close the file after initializing the table, NEURON will just append the data below the initialized table. What I want is NEURON to replace some of the 9999s by the actual data; or in other words, just writing over the file without formatting it.
Is there anyway I can do that?
I am generating a data table from a simulation. It is a table where line = sections in the neuron; and columns = times where an AP was recorded in each section (there is an APCount in each section). Eventually, I want each column of the file to represent the propagation of one AP through the neuron. APs do not overlap in time (the 1st is finished when the 2nd starts, etc.) so I guess it should be possible.
Problem is, as all APs do not propagate through the whole neuron, all lines do not get filled in at each iteration of the loop going through the sections. Thus, a shift appears in the columns, and columns may contain times belonging to the previous/next AP (not anymore one column = one AP). As I said, I want each AP to have its own column.
The solution I thought about was to first initialize a big table with values eg. 9999 (I'll be looking for the minimum of each column, hence the big number so it does not interfere). I'm first initializing the table (this works fine), then closing it. I want to re-open it and write over some of the 9999s. Now the issue is that NEURON formats the whole file if I try re-writing in it. The culprit seems to be wopen(): it is erasing the whole file each time it is called. However, if I don't close the file after initializing the table, NEURON will just append the data below the initialized table. What I want is NEURON to replace some of the 9999s by the actual data; or in other words, just writing over the file without formatting it.
Is there anyway I can do that?