That shouldn’t be too difficult as the formats are pretty basic.
The 2 main feed types are phpfina (PHP fixed interval no averaging) and phptimeseries.
phpfina is basically a pair of files, a
.dat which is a stream of 32bit floats end to end and a
.meta that records the interval and start time. Each 4bytes is a “interval” from the “start time” eg for a 10s feed the 40th - 43rd bytes are for start time + 100s (place in file 40/4 bytes = 10 intervals @ 10s). There is no time data stored for each datapoint as it’s position relative to the begining of the file (start time) gives you the timestamp. Any missing datapoints are
null. (see https://learn.openenergymonitor.org/electricity-monitoring/timeseries/Fixed-interval)
phptimeseries is a stream of 4 byte integer timestamps (unix) and 4byte floatss plus one unused byte (9bytes in total). (see https://learn.openenergymonitor.org/electricity-monitoring/timeseries/Variable-interval)
Which type you use will depend on your data.
Another way to do this could be to create a simple script that uses your csv to repost the data in chronological order starting with the oldest/first data. emoncms can accept data that is up to 4 years old and has a bulk upload API so you could upload via the emoncms inputs rather than playing with raw files, neither is ideal I know, just giving you another option.
Did you flash the new image to your original sdcard? If you have by any chance used another sdcard, you could easily mount your old sdcard and get at the raw data files and mysql table even though the update failed. The data will not have been affected by the failed update, just the running of that os and emoncms instance will have been screwed up by the update so retrieving the data may still be possible unless you have over written with the new image.