Software Open Access

detect-delimiter software project

McNamara, Timothy S


MARC21 XML Export

<?xml version='1.0' encoding='UTF-8'?>
<record xmlns="http://www.loc.gov/MARC21/slim">
  <leader>00000nmm##2200000uu#4500</leader>
  <datafield tag="041" ind1=" " ind2=" ">
    <subfield code="a">eng</subfield>
  </datafield>
  <datafield tag="653" ind1=" " ind2=" ">
    <subfield code="a">text processing</subfield>
  </datafield>
  <datafield tag="653" ind1=" " ind2=" ">
    <subfield code="a">Python programming</subfield>
  </datafield>
  <controlfield tag="005">20200125192153.0</controlfield>
  <datafield tag="500" ind1=" " ind2=" ">
    <subfield code="a">This Python package can also be installed via "pip": "pip install detect-delimiter".</subfield>
  </datafield>
  <controlfield tag="001">1323186</controlfield>
  <datafield tag="856" ind1="4" ind2=" ">
    <subfield code="s">3100</subfield>
    <subfield code="z">md5:768cebf9960d9c9f2ba4168f315fcf68</subfield>
    <subfield code="u">https://zenodo.org/record/1323186/files/detect_delimiter-0.1.1.tar.gz</subfield>
  </datafield>
  <datafield tag="542" ind1=" " ind2=" ">
    <subfield code="l">open</subfield>
  </datafield>
  <datafield tag="260" ind1=" " ind2=" ">
    <subfield code="c">2018-07-29</subfield>
  </datafield>
  <datafield tag="909" ind1="C" ind2="O">
    <subfield code="p">software</subfield>
    <subfield code="o">oai:zenodo.org:1323186</subfield>
  </datafield>
  <datafield tag="100" ind1=" " ind2=" ">
    <subfield code="u">DOT loves data</subfield>
    <subfield code="0">(orcid)0000-0002-2494-2700</subfield>
    <subfield code="a">McNamara, Timothy S</subfield>
  </datafield>
  <datafield tag="245" ind1=" " ind2=" ">
    <subfield code="a">detect-delimiter software project</subfield>
  </datafield>
  <datafield tag="540" ind1=" " ind2=" ">
    <subfield code="u">https://creativecommons.org/licenses/by/4.0/legalcode</subfield>
    <subfield code="a">Creative Commons Attribution 4.0 International</subfield>
  </datafield>
  <datafield tag="650" ind1="1" ind2="7">
    <subfield code="a">cc-by</subfield>
    <subfield code="2">opendefinition.org</subfield>
  </datafield>
  <datafield tag="520" ind1=" " ind2=" ">
    <subfield code="a">&lt;p&gt;Data sharing and research collaboration is hindered when messy data is released. Despite this, it still exists. detect-delimiter aims to provide tools with an option for inspecting the header of a text file and checking the actual delimiter used, rather than blindly believing the file extension.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The detect_delimiter module exposes the detect() functinon, which takes a str as input and returns a delimiter.&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-python"&gt;&amp;gt;&amp;gt;&amp;gt; from detect_delimiter import detect
&amp;gt;&amp;gt;&amp;gt; detect("looks|like|the vertical bar\n is|the|delimiter\n")
'|'&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When detect() doesn&amp;#39;t know, it returns None:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-python"&gt;&amp;gt;&amp;gt;&amp;gt; text = "not really any delimiters in here.\nthis is just text.\n"
&amp;gt;&amp;gt;&amp;gt; detect()&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It&amp;#39;s possible to provide a default, which will be used in that case:&lt;/p&gt;

&lt;pre&gt;&lt;code class="language-python"&gt;&amp;gt;&amp;gt;&amp;gt; detect(text, default=',')
','&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br&gt;
By default, detect() will prevent avoid checking alpha-numeric characters and the period/full stop character (&amp;quot;.&amp;quot;). This can be adjusted via the blacklist parameter.&lt;/p&gt;

&lt;p&gt;If you believe that you know the delimiter, it&amp;#39;s possible to provide a list of possible delimiters to check for via the whitelist parameter. If you don&amp;#39;t provide a value, [&amp;#39;,&amp;#39;, &amp;#39;;&amp;#39;, &amp;#39;:&amp;#39;, &amp;#39;|&amp;#39;, &amp;#39;\t&amp;#39;] will be checked.&lt;/p&gt;</subfield>
  </datafield>
  <datafield tag="773" ind1=" " ind2=" ">
    <subfield code="n">doi</subfield>
    <subfield code="i">isVersionOf</subfield>
    <subfield code="a">10.5281/zenodo.1323185</subfield>
  </datafield>
  <datafield tag="024" ind1=" " ind2=" ">
    <subfield code="a">10.5281/zenodo.1323186</subfield>
    <subfield code="2">doi</subfield>
  </datafield>
  <datafield tag="980" ind1=" " ind2=" ">
    <subfield code="a">software</subfield>
  </datafield>
</record>
112
23
views
downloads
All versions This version
Views 112112
Downloads 2323
Data volume 71.3 kB71.3 kB
Unique views 101101
Unique downloads 2222

Share

Cite as