<!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>Descriptor Exporter — Stem 1.1.0 documentation</title> <link rel="stylesheet" href="../../_static/haiku.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="../../_static/print.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '1.1.0', 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/theme_extras.js"></script> <link rel="shortcut icon" href="../../_static/favicon.png"/> <link rel="top" title="Stem 1.1.0 documentation" href="../../index.html" /> <link rel="up" title="Contents" href="../../contents.html" /> <link rel="next" title="Descriptor Reader" href="reader.html" /> <link rel="prev" title="TorDNSEL Exit Lists" href="tordnsel.html" /> </head> <body> <div class="header"><img class="rightlogo" src="../../_static/logo.png" alt="Logo"/><h1 class="heading"><a href="../../index.html"> <span>Stem Docs</span></a></h1> <h2 class="heading"><span>Descriptor Exporter</span></h2> </div> <div class="topnav"> <p> <ul id="navbar"> <li><a href="../../index.html">Home</a></li> <li><a href="../../tutorials.html">Tutorials</a> <ul> <li><a href="../../tutorials/the_little_relay_that_could.html">Hello World</a></li> <li><a href="../../tutorials/to_russia_with_love.html">Client Usage</a></li> <li><a href="../../tutorials/tortoise_and_the_hare.html">Event Listening</a></li> <li><a href="../../tutorials/mirror_mirror_on_the_wall.html">Tor Descriptors</a></li> <li><a href="../../tutorials/east_of_the_sun.html">Utilities</a></li> <li><a href="../../tutorials/double_double_toil_and_trouble.html">Examples</a></li> </ul> </li> <li><a href="../../api.html">API</a> <ul> <li><a href="../control.html">stem.control</a></li> <li><a href="../connection.html">stem.connection</a></li> <li><a href="../socket.html">stem.socket</a></li> <li><a href="../process.html">stem.process</a></li> <li><a href="../response.html">stem.response</a></li> <li><a href="../exit_policy.html">stem.exit_policy</a></li> <li><a href="../version.html">stem.version</a></li> <li><a href="../../api.html#descriptors">Descriptors</a></li> <li><a href="../../api.html#utilities">Utilities</a></li> </ul> </li> <li><a href="https://trac.torproject.org/projects/tor/wiki/doc/stem">Development</a> <ul> <li><a href="../../faq.html">FAQ</a></li> <li><a href="../../change_log.html">Change Log</a></li> <li><a href="https://trac.torproject.org/projects/tor/wiki/doc/stem/bugs">Bug Tracker</a></li> <li><a href="../../download.html">Download</a></li> </ul> </li> </ul> </p> </div> <div class="content"> <div class="section" id="module-stem.descriptor.export"> <span id="descriptor-exporter"></span><h1>Descriptor Exporter<a class="headerlink" href="#module-stem.descriptor.export" title="Permalink to this headline">¶</a></h1> <p>Toolkit for exporting descriptors to other formats.</p> <p><strong>Module Overview:</strong></p> <div class="highlight-python"><pre>export_csv - Exports descriptors to a CSV export_csv_file - Writes exported CSV output to a file</pre> </div> <dl class="function"> <dt id="stem.descriptor.export.export_csv"> <tt class="descclassname">stem.descriptor.export.</tt><tt class="descname">export_csv</tt><big>(</big><em>descriptors</em>, <em>included_fields=()</em>, <em>excluded_fields=()</em>, <em>header=True</em><big>)</big><a class="reference internal" href="../../_modules/stem/descriptor/export.html#export_csv"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.descriptor.export.export_csv" title="Permalink to this definition">¶</a></dt> <dd><p>Provides a newline separated CSV for one or more descriptors. If simply provided with descriptors then the CSV contains all of its attributes, labeled with a header row. Either ‘included_fields’ or ‘excluded_fields’ can be used for more granular control over its attributes and the order.</p> <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"><ul class="first simple"> <li><strong>descriptors</strong> (<em>Descriptor,list</em>) – either a <tt class="xref py py-class docutils literal"><span class="pre">Descriptor</span></tt> or list of descriptors to be exported</li> <li><strong>included_fields</strong> (<em>list</em>) – attributes to include in the csv</li> <li><strong>excluded_fields</strong> (<em>list</em>) – attributes to exclude from the csv</li> <li><strong>header</strong> (<em>bool</em>) – if <strong>True</strong> then the first line will be a comma separated list of the attribute names (<strong>only supported in python 2.7 and higher</strong>)</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>str</strong> of the CSV for the descriptors, one per line</p> </td> </tr> <tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last"><strong>ValueError</strong> if descriptors contain more than one descriptor type</p> </td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="stem.descriptor.export.export_csv_file"> <tt class="descclassname">stem.descriptor.export.</tt><tt class="descname">export_csv_file</tt><big>(</big><em>output_file</em>, <em>descriptors</em>, <em>included_fields=()</em>, <em>excluded_fields=()</em>, <em>header=True</em><big>)</big><a class="reference internal" href="../../_modules/stem/descriptor/export.html#export_csv_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#stem.descriptor.export.export_csv_file" title="Permalink to this definition">¶</a></dt> <dd><p>Similar to <a class="reference internal" href="#stem.descriptor.export.export_csv" title="stem.descriptor.export.export_csv"><tt class="xref py py-func docutils literal"><span class="pre">stem.descriptor.export.export_csv()</span></tt></a>, except that the CSV is written directly to a file.</p> <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"><ul class="first simple"> <li><strong>output_file</strong> (<em>file</em>) – file to be written to</li> <li><strong>descriptors</strong> (<em>Descriptor,list</em>) – either a <tt class="xref py py-class docutils literal"><span class="pre">Descriptor</span></tt> or list of descriptors to be exported</li> <li><strong>included_fields</strong> (<em>list</em>) – attributes to include in the csv</li> <li><strong>excluded_fields</strong> (<em>list</em>) – attributes to exclude from the csv</li> <li><strong>header</strong> (<em>bool</em>) – if <strong>True</strong> then the first line will be a comma separated list of the attribute names (<strong>only supported in python 2.7 and higher</strong>)</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>str</strong> of the CSV for the descriptors, one per line</p> </td> </tr> <tr class="field-odd field"><th class="field-name">Raises :</th><td class="field-body"><p class="first last"><strong>ValueError</strong> if descriptors contain more than one descriptor type</p> </td> </tr> </tbody> </table> </dd></dl> </div> </div> <div class="bottomnav"> </div> <div class="footer"> </div> </body> </html>