In my last post I griped about the Tektronix TDS2004B spitting out horrible CSV files. I wrote this script to reformat it. As you can see from the source, whatever is in the “header” file just gets dumped ahead of the data. I just checked it and it should work with 1, 2, 3, or 4 channel files.
-
#Formats the horrendous TDS****B CSV data files into a format
-
#compatible with GNUplot
-
‘The header file is simply prepended to the data.’‘nnnUsage:TDSformat.py <csv> <out>.n%snnn’‘r’‘r’‘w’‘n’‘,’)
-
-
#First, spit out the lines as they are.
-
#4 channels
-
‘%st%st%st%st%s’#3 channels
-
‘%st%st%st%s’#2 channels
-
‘%st%st%s’#1 channel
-
‘%st%s’ % (
-
cols[3], cols[4] )
-
-
#Now change the "." to 0’s.
-
‘.’‘.’‘.’‘.’#Write the data in the new file.
-
‘%et%e’‘t%e’‘t%e’‘t%e’‘n’
This should get you started.
Post a Comment