@richardk
Hey Richard, Sorry I wasn't ignoring you. I'm retired, but an old customer talked me in to helping him out for a few days.
Anyway here is some info you may find interesting, or may already know?
Most bench DSO's support csv's directly. The format varies widely but basically you will have the following.
Headers will often include date time instrument settings and sample width or samples per second and total number of samples. In real life this varies greatly.
Body format single trace. Most scopes have the ability to output acquisition time and number information but it's not always clear how to accomplish it.
acquisition time, voltage
acquisition number, voltage
voltage
Body format multiple trace.
acquisition time, voltage, acquisition time, voltage (acquisition time will vary depends on channel sharing)
acquisition number, voltage, voltage
voltage, voltage
So here are a couple of scenarios for csv's
- Exporting a csv for use in excel. Acquisition time is very useful. If number is used then duration of the sample should be in the header.
- Exporting a csv for use in a bench DSO. This relies heavily on header information and the record length of the body. My routine was to used an existing header, paste in a body then count the number of records. I would never attempt to add that type of functionality. Way too much grief.
- Importing a waveform from a DSO. If you have two columns the second will be the voltage. If the first is time you could load accordingly. If the first is a sample/record number then you will need to know what amount of time each datapoint represents. That could be included in the header but I'd suggest asking the user. If there are not enough records just fill with zeros and leave at that. If there are too many records just load what you can. Although you could interpolate datapoints while loading I do not think it would be an issue to use the last record value until you arrive at a change or to skip / average multiple points.
- Importing a waveform from a program. Ltspice output (for example) is acquisition time voltage and on and on (I didn't check the separator). You could load in the same way as a DSO or read through the body to calculate the time that each datapoint covers. Ideally you would be able to time shift this type waveform after it has been loaded. In any case this would probably be the most used feature. Being able match simulated waveforms with a realworld design kinda neat.
My thoughts csv would be
Multi trace output in any format you like.
Single trace reference load which skips the header if not Hantek and asks or has a place to input the datapoint duration.
Possibly allow the user to select the voltage column
I'm not sure about multi trace load but would probably not allow it unless the header math information matches the Hantek. Mainly that is because the math trace needs the math information to be displayed correctly. This is supported in the native save.
If the csv has more than 1 column then column 2 is probably voltage
I've added a few csv's for you to look at. The siglent is to show you variants from the same scope.
Please feel free to discard anything I say.