<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>BaseSplitter — Astropy v0.2.4</title> <link rel="stylesheet" href="../_static/bootstrap-astropy.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.2.4', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="shortcut icon" href="../_static/astropy_logo.ico"/> <link rel="top" title="Astropy v0.2.4" href="../index.html" /> <link rel="up" title="ASCII Tables (astropy.io.ascii)" href="../io/ascii/index.html" /> <link rel="next" title="Basic" href="astropy.io.ascii.basic.Basic.html" /> <link rel="prev" title="BaseReader" href="astropy.io.ascii.core.BaseReader.html" /> </head> <body> <div class="topbar"> <a class="brand" title="Documentation Home" href="../index.html"></a> <ul> <li><a class="homelink" title="AstroPy Homepage" href="http://www.astropy.org"></a></li> <li><a title="General Index" href="../genindex.html">Index</a></li> <li><a title="Python Module Index" href="../py-modindex.html">Modules</a></li> <li> <form action="../search.html" method="get"> <input type="text" name="q" placeholder="Search" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </li> </ul> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right"> <a href="astropy.io.ascii.basic.Basic.html" title="Basic"> next » </a> </li> <li class="right"> <a href="astropy.io.ascii.core.BaseReader.html" title="BaseReader"> « previous </a> | </li> <li> <a href="../index.html">Astropy v0.2.4</a> » </li> <li><a href="../io/ascii/index.html" accesskey="U">ASCII Tables (<tt class="docutils literal"><span class="pre">astropy.io.ascii</span></tt>)</a> »</li> <li>BaseSplitter</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="basesplitter"> <h1>BaseSplitter<a class="headerlink" href="#basesplitter" title="Permalink to this headline">¶</a></h1> <dl class="class"> <dt id="astropy.io.ascii.core.BaseSplitter"> <em class="property">class </em><tt class="descclassname">astropy.io.ascii.core.</tt><tt class="descname">BaseSplitter</tt><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/ascii/core.py#L175" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link"> [edit on github]</span></a><a class="reference internal" href="../_modules/astropy/io/ascii/core.html#BaseSplitter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#astropy.io.ascii.core.BaseSplitter" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> <p>Base splitter that uses python’s split method to do the work.</p> <p>This does not handle quoted values. A key feature is the formulation of __call__ as a generator that returns a list of the split line values at each iteration.</p> <p>There are two methods that are intended to be overridden, first <tt class="docutils literal"><span class="pre">process_line()</span></tt> to do pre-processing on each input line before splitting and <tt class="docutils literal"><span class="pre">process_val()</span></tt> to do post-processing on each split string value. By default these apply the string <tt class="docutils literal"><span class="pre">strip()</span></tt> function. These can be set to another function via the instance attribute or be disabled entirely, for example:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">reader</span><span class="o">.</span><span class="n">header</span><span class="o">.</span><span class="n">splitter</span><span class="o">.</span><span class="n">process_val</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="o">.</span><span class="n">lstrip</span><span class="p">()</span> <span class="n">reader</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">splitter</span><span class="o">.</span><span class="n">process_val</span> <span class="o">=</span> <span class="bp">None</span> </pre></div> </div> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>delimiter</strong> – one-character string used to separate fields</td> </tr> </tbody> </table> <p class="rubric">Attributes Summary</p> <table border="1" class="longtable docutils"> <colgroup> <col width="10%" /> <col width="90%" /> </colgroup> <tbody valign="top"> <tr class="row-odd"><td><a class="reference internal" href="#astropy.io.ascii.core.BaseSplitter.delimiter" title="astropy.io.ascii.core.BaseSplitter.delimiter"><tt class="xref py py-obj docutils literal"><span class="pre">delimiter</span></tt></a></td> <td></td> </tr> </tbody> </table> <p class="rubric">Methods Summary</p> <table border="1" class="longtable docutils"> <colgroup> <col width="10%" /> <col width="90%" /> </colgroup> <tbody valign="top"> <tr class="row-odd"><td><a class="reference internal" href="#astropy.io.ascii.core.BaseSplitter.join" title="astropy.io.ascii.core.BaseSplitter.join"><tt class="xref py py-obj docutils literal"><span class="pre">join</span></tt></a>(vals)</td> <td></td> </tr> <tr class="row-even"><td><a class="reference internal" href="#astropy.io.ascii.core.BaseSplitter.process_line" title="astropy.io.ascii.core.BaseSplitter.process_line"><tt class="xref py py-obj docutils literal"><span class="pre">process_line</span></tt></a>(line)</td> <td>Remove whitespace at the beginning or end of line.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="#astropy.io.ascii.core.BaseSplitter.process_val" title="astropy.io.ascii.core.BaseSplitter.process_val"><tt class="xref py py-obj docutils literal"><span class="pre">process_val</span></tt></a>(val)</td> <td>Remove whitespace at the beginning or end of value.</td> </tr> </tbody> </table> <p class="rubric">Attributes Documentation</p> <dl class="attribute"> <dt id="astropy.io.ascii.core.BaseSplitter.delimiter"> <tt class="descname">delimiter</tt><em class="property"> = None</em><a class="headerlink" href="#astropy.io.ascii.core.BaseSplitter.delimiter" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p class="rubric">Methods Documentation</p> <dl class="method"> <dt id="astropy.io.ascii.core.BaseSplitter.join"> <tt class="descname">join</tt><big>(</big><em>vals</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/ascii/core.py#L215" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link"> [edit on github]</span></a><a class="reference internal" href="../_modules/astropy/io/ascii/core.html#BaseSplitter.join"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#astropy.io.ascii.core.BaseSplitter.join" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="astropy.io.ascii.core.BaseSplitter.process_line"> <tt class="descname">process_line</tt><big>(</big><em>line</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/ascii/core.py#L196" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link"> [edit on github]</span></a><a class="reference internal" href="../_modules/astropy/io/ascii/core.html#BaseSplitter.process_line"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#astropy.io.ascii.core.BaseSplitter.process_line" title="Permalink to this definition">¶</a></dt> <dd><p>Remove whitespace at the beginning or end of line. This is especially useful for whitespace-delimited files to prevent spurious columns at the beginning or end.</p> </dd></dl> <dl class="method"> <dt id="astropy.io.ascii.core.BaseSplitter.process_val"> <tt class="descname">process_val</tt><big>(</big><em>val</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/ascii/core.py#L201" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link"> [edit on github]</span></a><a class="reference internal" href="../_modules/astropy/io/ascii/core.html#BaseSplitter.process_val"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#astropy.io.ascii.core.BaseSplitter.process_val" title="Permalink to this definition">¶</a></dt> <dd><p>Remove whitespace at the beginning or end of value.</p> </dd></dl> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"><h3>Page Contents</h3> <ul> <li><a class="reference internal" href="#">BaseSplitter</a></li> </ul> </div> </div> <div class="clearer"></div> </div> <footer class="footer"> <p class="pull-right"> <a href="../_sources/_generated/astropy.io.ascii.core.BaseSplitter.txt" rel="nofollow">Page Source</a> <a href="#">Back to Top</a></p> <p> © Copyright 2011-2013, The Astropy Developers.<br/> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. Last built 22 Oct 2013. <br/> </p> </footer> </body> </html>