Skip to content

Python script to format the TDS B series CSV files.

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.

  1. #Formats the horrendous TDS****B CSV data files into a format
  2. #compatible with GNUplot
  3. ‘The header file is simply prepended to the data.’‘ <csv>  <out>.n%snnn’‘r’‘r’‘w’‘n’‘,’)
  5.     #First, spit out the lines as they are.
  6. #4 channels
  7. ‘%st%st%st%st%s’#3 channels
  8. ‘%st%st%st%s’#2 channels
  9. ‘%st%st%s’#1 channel
  10. ‘%st%s’ % (
  11.             cols[3], cols[4] )
  13.     #Now change the "." to 0’s.
  14. ‘.’‘.’‘.’‘.’#Write the data in the new file.
  15. ‘%et%e’‘t%e’‘t%e’‘t%e’‘n’

This should get you started.

Post a Comment

Your email is never published nor shared. Required fields are marked *