<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="http://starling.us/gus_xslt.xsl"?>
<gus_xslt
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://starling.ws/XML/gus_xslt.xsd">
<head>
  <navigation ToC="Table of Contents" 
    section="yes" topic="yes" subtopic="yes" subsubtopic="yes" links="yes"/>
  <syndication atom="http://starling.us/starling_us_atom.xml" />
  <cgi img="no" img_action="../cgi-bin/gus_web_photo.pl" img_path="../gus_calc_generic_pl" />
  <pdfmarks body="no" section="no" topic="no" subtopic="no" subsubtopic="no"/>
  <title>Perl Script</title>
  <description>Perl Script</description>
  <keywords>Perl, Starling</keywords>
  <author>Gan Uesli Starling</author>
  <copyright>2007, Gan Uesli Starling</copyright>
</head>
<body>
  <title>Perl Script <code>gus_tek_csv_merge.pl</code></title>
  <p class="center" style="line-height:150%;">copyright 2007<br/>by Ĝan Ŭesli Starling</p>

  <section>
    <title>Introduction</title>
    <p>Where I work we have a Tektronix 4-channel digital oscilloscope which saves data in <code>*.csv</code> format. That is good. The bad part is that it saves a separate file for each channel, even though they are synchronous. So what this script does is merge two <code>*.csv</code> files back into one, then graphs them.</p>    
  </section>
  
  <section>
    <title>Merging CSV Files</title>
    <p>Suppose you have a pair of <code>TEK00000.CSV</code> files that look sort of like this...</p>
   
<pre>
'Time (S)','Spray (V)',
-.0999724,.2
-.0995724,.2
-.0991724,-.6
-.0987724,-.2
</pre>

    <p>...for one, and a second file, <code>TEK00001.CSV</code> which looks like this...</p>
    
<pre>'Time (S)','Scan (V)',
-.0999752,.2
-.0995752,.2
-.0991752,.2
-.0987752,.2
</pre>

    <p>...for the other.</p>
    
    <p>Not exactly like that, since each would be longer by hundreds of lines. But that general kind of layout where...</p>
    
    <ul>
      <li>The first (top) line you will have inserted after collection so as to identify the data for posterity.</li>
      <li>The 2nd thru Nth lines are the original 1st thru Nth lines of the raw <code>TEK0000*.CSV</code> file.</li>
    </ul>
    
    <p>And say you want to merge those two files so as to have one output <code>TEK00000-TEK00001.csv</code> file which looks like this...</p>
    
<pre>'Time (S)', 'Spray (V)', 'Scan (V)'
    -0.1000,        0.20,       0.20
    -0.0996,        0.20,       0.20
    -0.0992,       -0.60,       0.20
    -0.0988,       -0.20,       0.20
</pre>

    <p>...but again of several hundred lines. And say you would also like an explanitory file named <code>TEK00000-TEK00001.csv.info</code> which should look rather like this...</p>

<pre>
'Column Order' = 0
'Column Name' =   'Time (S)'
'Dimension' = Time
'Unit' = Seconds (S)
'Data Length' = 500

'Column Order' = 1
'Column Name' =   'Spray (V)'
'Dimension' = Amplitude
'Unit' = Volts (V)
'Data Length' = 500

'Column Order' = 2
'Column Name' =   'Scan (V)'
'Dimension' = Amplitude
'Unit' = Volts (V)
'Data Length' = 500
</pre>

    <p></p>

  </section>
  
  <section>
    <title>Download</title>
    
    <p>My script <code>gus_tek_csv_merge.pl</code> will perform as described above on any pair of <code>CSV</code> input files. Although this script has no built-in GUI, a separate GUI is also provided in its own pair of download links.</p>
    
    <!--
    
    Dear Maintainer,
    
    Please note! Within the original maintenance directory, the *.txt extensions are not used.
    Therein the original, bare *.pl and *.csv extensions are in force. So perform uploads to
    any web servers via FTP as below...
    
    ftp> put foo.pl foo.txt
    ftp> put foo.csv foo.txt
    
    ...and so forth or the download links in this text will break.
    
    -->
  
    <topic>
      <title>Scripts</title>
      <p>Here are links relating to the command-line version of this script.</p>
      
<p><code>Script:&#160;</code>
<a class="button" href="./gus_tek_csv_merge.html">POD as HTML</a>
&#160;
<a class="button" href="./gus_tek_csv_merge.txt">Perl as TXT</a>
</p>
    </topic> 
    
    <topic>
      <title>Auxilliary GUI</title>
      <p>Here is the separate GUI, written in Perl/Tk which will interface to (call and run on command) the above GUI-less Perl script. This is my new methodology for dealing with simple scripts, rather than build in a custom GUI for each.</p>

<p><code>Script:&#160;</code>
<a class="button" href="./gus_tek_csv_merge_EasyGUI.html">POD as HTML</a>
&#160;
<a class="button" href="./gus_tek_csv_merge_EasyGUI.txt">Perl as TXT</a>
</p>
    </topic> 
    
    <topic>
      <title>Example CSV Files</title>
      <p>To test the above script (with or without its GUI) you will need a pair of Tektronix data files. Here are two for you to play with.</p>

<p><code>Inputs:&#160;</code>
<a class="button" href="./TEK00000.txt">CSV as TXT</a>
&#160;
<a class="button" href="./TEK00001.txt">CSV as TXT</a>
</p>
    </topic> 
    
    <topic>
      <title>Custom Dependencies</title>
      <p>This script has Perl module dependencies some of which are not yet on CPAN. Download them from here.</p>
    
<p><code>Module:&#160;</code>
<a class="button" href="../gus_perl_modules/index.xml#Chart-EPS_graph">XML</a> 
&#160;<code>Chart::EPS_graph</code>

<br/><code>Module:&#160;</code>
<a class="button" href="../gus_perl_modules/index.xml#Text-CSV-Munge">XML</a> 
&#160;<code>Text::CSV::Munge</code>

<br/><code>Module:&#160;</code>
<a class="button" href="../gus_perl_modules/index.xml#Tk-EasyGUI">XML</a> 
&#160;<code>Tk::EasyGUI</code>
</p>
    </topic>
    
  </section> 
  
  
</body>
</gus_xslt>
