/usr/share/doc/python-tables-doc/html/usersguide/utilities.html is in python-tables-doc 3.1.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | <!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>Utilities — PyTables 3.1.1 documentation</title>
<link rel="stylesheet" href="../_static/cloud.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '3.1.1',
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/jquery.cookie.js"></script>
<script type="text/javascript" src="../_static/toggle_sections.js"></script>
<script type="text/javascript" src="../_static/toggle_sidebar.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="top" title="PyTables 3.1.1 documentation" href="../index.html" />
<link rel="up" title="PyTables User’s Guide" href="index.html" />
<link rel="next" title="PyTables File Format" href="file_format.html" />
<link rel="prev" title="PyTables parameter files" href="parameter_files.html" />
</head>
<body>
<div class="relbar-top">
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> </li>
<li class="right" >
<a href="../np-modindex.html" title="Python Module Index"
>modules</a> </li>
<li class="right" >
<a href="file_format.html" title="PyTables File Format"
accesskey="N">next</a> </li>
<li class="right" >
<a href="parameter_files.html" title="PyTables parameter files"
accesskey="P">previous</a> </li>
<li><a href="../index.html">PyTables 3.1.1 documentation</a> »</li>
<li><a href="index.html" accesskey="U">PyTables User’s Guide</a> »</li>
</ul>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="utilities">
<h1>Utilities<a class="headerlink" href="#utilities" title="Permalink to this headline">¶</a></h1>
<p>PyTables comes with a couple of utilities that make the life easier to the
user. One is called ptdump and lets you see the contents of a PyTables file
(or generic HDF5 file, if supported). The other one is named ptrepack that
allows to (recursively) copy sub-hierarchies of objects present in a file
into another one, changing, if desired, some of the filters applied to the
leaves during the copy process.</p>
<p>Normally, these utilities will be installed somewhere in your PATH during the
process of installation of the PyTables package, so that you can invoke them
from any place in your file system after the installation has successfully
finished.</p>
<div class="section" id="ptdump">
<h2>ptdump<a class="headerlink" href="#ptdump" title="Permalink to this headline">¶</a></h2>
<p>As has been said before, ptdump utility allows you look into the contents of
your PyTables files. It lets you see not only the data but also the metadata
(that is, the <em>structure</em> and additional information in the form of
<em>attributes</em>).</p>
<div class="section" id="usage">
<h3>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h3>
<p>For instructions on how to use it, just pass the -h flag to the command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -h
</pre></div>
</div>
<p>to see the message usage:</p>
<div class="highlight-bash"><div class="highlight"><pre>usage: ptdump <span class="o">[</span>-d<span class="o">]</span> <span class="o">[</span>-v<span class="o">]</span> <span class="o">[</span>-a<span class="o">]</span> <span class="o">[</span>-c<span class="o">]</span> <span class="o">[</span>-i<span class="o">]</span> <span class="o">[</span>-R start,stop,step<span class="o">]</span> <span class="o">[</span>-h<span class="o">]</span> file<span class="o">[</span>:nodepath<span class="o">]</span>
-d -- Dump data information on leaves
-v -- Dump more metainformation on nodes
-a -- Show attributes in nodes <span class="o">(</span>only useful when -v or -d are active<span class="o">)</span>
-c -- Show info of columns in tables <span class="o">(</span>only useful when -v or -d are active<span class="o">)</span>
-i -- Show info of indexed columns <span class="o">(</span>only useful when -v or -d are active<span class="o">)</span>
-R RANGE -- Select a RANGE of rows in the form <span class="s2">"start,stop,step"</span>
-h -- Print <span class="nb">help </span>on usage
</pre></div>
</div>
<p>Read on for a brief introduction to this utility.</p>
</div>
<div class="section" id="a-small-tutorial-on-ptdump">
<h3>A small tutorial on ptdump<a class="headerlink" href="#a-small-tutorial-on-ptdump" title="Permalink to this headline">¶</a></h3>
<p>Let’s suppose that we want to know only the <em>structure</em> of a file. In order
to do that, just don’t pass any flag, just the file as parameter.</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump vlarray1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of ints'</span>
/vlarray2 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of strings'</span>
</pre></div>
</div>
<p>we can see that the file contains just a leaf object called vlarray1, that is
an instance of VLArray, has 4 rows, and two filters has been used in order to
create it: shuffle and zlib (with a compression level of 1).</p>
<p>Let’s say we want more meta-information. Just add the -v (verbose) flag:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -v vlarray1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of ints'</span>
<span class="nv">atom</span> <span class="o">=</span> Int32Atom<span class="o">(</span><span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span>0<span class="o">)</span>
<span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">'little'</span>
<span class="nv">nrows</span> <span class="o">=</span> 3
<span class="nv">flavor</span> <span class="o">=</span> <span class="s1">'numpy'</span>
/vlarray2 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of strings'</span>
<span class="nv">atom</span> <span class="o">=</span> StringAtom<span class="o">(</span><span class="nv">itemsize</span><span class="o">=</span>2, <span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span><span class="s1">''</span><span class="o">)</span>
<span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">'irrelevant'</span>
<span class="nv">nrows</span> <span class="o">=</span> 3
<span class="nv">flavor</span> <span class="o">=</span> <span class="s1">'python'</span>
</pre></div>
</div>
<p>so we can see more info about the atoms that are the components of the
vlarray1 dataset, i.e. they are scalars of type Int32 and with NumPy
<em>flavor</em>.</p>
<p>If we want information about the attributes on the nodes, we must add the -a
flag:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -va vlarray1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/._v_attrs <span class="o">(</span>AttributeSet<span class="o">)</span>, 4 attributes:
<span class="o">[</span>CLASS :<span class="o">=</span> <span class="s1">'GROUP'</span>,
PYTABLES_FORMAT_VERSION :<span class="o">=</span> <span class="s1">'2.0'</span>,
TITLE :<span class="o">=</span> <span class="s1">''</span>,
VERSION :<span class="o">=</span> <span class="s1">'1.0'</span><span class="o">]</span>
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of ints'</span>
<span class="nv">atom</span> <span class="o">=</span> Int32Atom<span class="o">(</span><span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span>0<span class="o">)</span>
<span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">'little'</span>
<span class="nv">nrows</span> <span class="o">=</span> 3
<span class="nv">flavor</span> <span class="o">=</span> <span class="s1">'numpy'</span>
/vlarray1._v_attrs <span class="o">(</span>AttributeSet<span class="o">)</span>, 3 attributes:
<span class="o">[</span>CLASS :<span class="o">=</span> <span class="s1">'VLARRAY'</span>,
TITLE :<span class="o">=</span> <span class="s1">'ragged array of ints'</span>,
VERSION :<span class="o">=</span> <span class="s1">'1.3'</span><span class="o">]</span>
/vlarray2 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of strings'</span>
<span class="nv">atom</span> <span class="o">=</span> StringAtom<span class="o">(</span><span class="nv">itemsize</span><span class="o">=</span>2, <span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span><span class="s1">''</span><span class="o">)</span>
<span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">'irrelevant'</span>
<span class="nv">nrows</span> <span class="o">=</span> 3
<span class="nv">flavor</span> <span class="o">=</span> <span class="s1">'python'</span>
/vlarray2._v_attrs <span class="o">(</span>AttributeSet<span class="o">)</span>, 4 attributes:
<span class="o">[</span>CLASS :<span class="o">=</span> <span class="s1">'VLARRAY'</span>,
FLAVOR :<span class="o">=</span> <span class="s1">'python'</span>,
TITLE :<span class="o">=</span> <span class="s1">'ragged array of strings'</span>,
VERSION :<span class="o">=</span> <span class="s1">'1.3'</span><span class="o">]</span>
</pre></div>
</div>
<p>Let’s have a look at the real data:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -d vlarray1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of ints'</span>
Data dump:
<span class="o">[</span>0<span class="o">]</span> <span class="o">[</span>5 6<span class="o">]</span>
<span class="o">[</span>1<span class="o">]</span> <span class="o">[</span>5 6 7<span class="o">]</span>
<span class="o">[</span>2<span class="o">]</span> <span class="o">[</span>5 6 9 8<span class="o">]</span>
/vlarray2 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of strings'</span>
Data dump:
<span class="o">[</span>0<span class="o">]</span> <span class="o">[</span><span class="s1">'5'</span>, <span class="s1">'66'</span><span class="o">]</span>
<span class="o">[</span>1<span class="o">]</span> <span class="o">[</span><span class="s1">'5'</span>, <span class="s1">'6'</span>, <span class="s1">'77'</span><span class="o">]</span>
<span class="o">[</span>2<span class="o">]</span> <span class="o">[</span><span class="s1">'5'</span>, <span class="s1">'6'</span>, <span class="s1">'9'</span>, <span class="s1">'88'</span><span class="o">]</span>
</pre></div>
</div>
<p>We see here a data dump of the 4 rows in vlarray1 object, in the form of a
list. Because the object is a VLA, we see a different number of integers on
each row.</p>
<p>Say that we are interested only on a specific <em>row range</em> of the /vlarray1
object:</p>
<div class="highlight-bash"><div class="highlight"><pre>ptdump -R2,3 -d vlarray1.h5:/vlarray1
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of ints'</span>
Data dump:
<span class="o">[</span>2<span class="o">]</span> <span class="o">[</span>5 6 9 8<span class="o">]</span>
</pre></div>
</div>
<p>Here, we have specified the range of rows between 2 and 4 (the upper limit
excluded, as usual in Python). See how we have selected only the /vlarray1
object for doing the dump (vlarray1.h5:/vlarray1).</p>
<p>Finally, you can mix several information at once:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump -R2,3 -vad vlarray1.h5:/vlarray1
/vlarray1 <span class="o">(</span>VLArray<span class="o">(</span>3,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'ragged array of ints'</span>
<span class="nv">atom</span> <span class="o">=</span> Int32Atom<span class="o">(</span><span class="nv">shape</span><span class="o">=()</span>, <span class="nv">dflt</span><span class="o">=</span>0<span class="o">)</span>
<span class="nv">byteorder</span> <span class="o">=</span> <span class="s1">'little'</span>
<span class="nv">nrows</span> <span class="o">=</span> 3
<span class="nv">flavor</span> <span class="o">=</span> <span class="s1">'numpy'</span>
/vlarray1._v_attrs <span class="o">(</span>AttributeSet<span class="o">)</span>, 3 attributes:
<span class="o">[</span>CLASS :<span class="o">=</span> <span class="s1">'VLARRAY'</span>,
TITLE :<span class="o">=</span> <span class="s1">'ragged array of ints'</span>,
VERSION :<span class="o">=</span> <span class="s1">'1.3'</span><span class="o">]</span>
Data dump:
<span class="o">[</span>2<span class="o">]</span> <span class="o">[</span>5 6 9 8<span class="o">]</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="ptrepack">
<span id="ptrepackdescr"></span><h2>ptrepack<a class="headerlink" href="#ptrepack" title="Permalink to this headline">¶</a></h2>
<p>This utility is a very powerful one and lets you copy any leaf, group or
complete subtree into another file. During the copy process you are allowed
to change the filter properties if you want so. Also, in the case of
duplicated pathnames, you can decide if you want to overwrite already
existing nodes on the destination file. Generally speaking, ptrepack can be
useful in may situations, like replicating a subtree in another file, change
the filters in objects and see how affect this to the compression degree or
I/O performance, consolidating specific data in repositories or even
<em>importing</em> generic HDF5 files and create true PyTables counterparts.</p>
<div class="section" id="id1">
<h3>Usage<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<p>For instructions on how to use it, just pass the -h flag to the command:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack -h
</pre></div>
</div>
<p>to see the message usage:</p>
<div class="highlight-bash"><div class="highlight"><pre>usage: ptrepack <span class="o">[</span>-h<span class="o">]</span> <span class="o">[</span>-v<span class="o">]</span> <span class="o">[</span>-o<span class="o">]</span> <span class="o">[</span>-R start,stop,step<span class="o">]</span> <span class="o">[</span>--non-recursive<span class="o">]</span> <span class="o">[</span>--dest-title<span class="o">=</span>title<span class="o">]</span> <span class="o">[</span>--dont-create-sysattrs<span class="o">]</span> <span class="o">[</span>--dont-copy-userattrs<span class="o">]</span> <span class="o">[</span>--overwrite-nodes<span class="o">]</span> <span class="o">[</span>--complevel<span class="o">=(</span>0-9<span class="o">)]</span> <span class="o">[</span>--complib<span class="o">=</span>lib<span class="o">]</span> <span class="o">[</span>--shuffle<span class="o">=(</span>0|1<span class="o">)]</span> <span class="o">[</span>--fletcher32<span class="o">=(</span>0|1<span class="o">)]</span> <span class="o">[</span>--keep-source-filters<span class="o">]</span> <span class="o">[</span>--chunkshape<span class="o">=</span>value<span class="o">]</span> <span class="o">[</span>--upgrade-flavors<span class="o">]</span> <span class="o">[</span>--dont-regenerate-old-indexes<span class="o">]</span> <span class="o">[</span>--sortby<span class="o">=</span>column<span class="o">]</span> <span class="o">[</span>--checkCSI<span class="o">]</span> <span class="o">[</span>--propindexes<span class="o">]</span> sourcefile:sourcegroup destfile:destgroup
-h -- Print usage message.
-v -- Show more information.
-o -- Overwrite destination file.
-R RANGE -- Select a RANGE of rows <span class="o">(</span>in the form <span class="s2">"start,stop,step"</span><span class="o">)</span>
during the copy of <span class="se">\*</span>all* the leaves. Default values are
<span class="s2">"None,None,1"</span>, which means a copy of all the rows.
--non-recursive -- Do not <span class="k">do </span>a recursive copy. Default is to <span class="k">do </span>it.
--dest-title<span class="o">=</span>title -- Title <span class="k">for </span>the new file <span class="o">(</span><span class="k">if </span>not specified,
the <span class="nb">source </span>is copied<span class="o">)</span>.
--dont-create-sysattrs -- Do not create sys attrs <span class="o">(</span>default is to <span class="k">do </span>it<span class="o">)</span>.
--dont-copy-userattrs -- Do not copy the user attrs <span class="o">(</span>default is to <span class="k">do </span>it<span class="o">)</span>.
--overwrite-nodes -- Overwrite destination nodes <span class="k">if </span>they exist. Default is
to not overwrite them.
--complevel<span class="o">=(</span>0-9<span class="o">)</span> -- Set a compression level <span class="o">(</span>0 <span class="k">for </span>no compression, which
is the default<span class="o">)</span>.
--complib<span class="o">=</span>lib -- Set the compression library to be used during the copy.
lib can be <span class="nb">set </span>to <span class="s2">"zlib"</span>, <span class="s2">"lzo"</span>, <span class="s2">"bzip2"</span> or <span class="s2">"blosc"</span>.
Additional compressors <span class="k">for </span>Blosc like <span class="s2">"blosc:blosclz"</span>,
<span class="s2">"blosc:lz4"</span>, <span class="s2">"blosc:lz4hc"</span>, <span class="s2">"blosc:snappy"</span> and
<span class="s2">"blosc:zlib"</span>, are supported too. Defaults to <span class="s2">"zlib"</span>.
--shuffle<span class="o">=(</span>0|1<span class="o">)</span> -- Activate or not the shuffling filter <span class="o">(</span>default is active
<span class="k">if </span>complevel>0<span class="o">)</span>.
--fletcher32<span class="o">=(</span>0|1<span class="o">)</span> -- Whether to activate or not the fletcher32 filter
<span class="o">(</span>not active by default<span class="o">)</span>.
--keep-source-filters -- Use the original filters in <span class="nb">source </span>files. The
default is not doing that <span class="k">if </span>any of --complevel, --complib, --shuffle
or --fletcher32 option is specified.
--chunkshape<span class="o">=(</span><span class="s2">"keep"</span><span class="se">\|</span><span class="s2">"auto"</span><span class="se">\|</span>int|tuple<span class="o">)</span> -- Set a chunkshape. A value
of <span class="s2">"auto"</span> computes a sensible value <span class="k">for </span>the chunkshape of the
leaves copied. The default is to <span class="s2">"keep"</span> the original value.
--upgrade-flavors -- When repacking PyTables 1.x files, the flavor of
leaves will be unset. With this, such a leaves will be serialized
as objects with the internal flavor <span class="o">(</span><span class="s1">'numpy'</span> <span class="k">for </span>2.x series<span class="o">)</span>.
--dont-regenerate-old-indexes -- Disable regenerating old indexes. The
default is to regenerate old indexes as they are found.
--sortby<span class="o">=</span>column -- Do a table copy sorted by the index in <span class="s2">"column"</span>.
For reversing the order, use a negative value in the <span class="s2">"step"</span> part of
<span class="s2">"RANGE"</span> <span class="o">(</span>see <span class="s2">"-R"</span> flag<span class="o">)</span>. Only applies to table objects.
--checkCSI -- Force the check <span class="k">for </span>a CSI index <span class="k">for </span>the --sortby column.
--propindexes -- Propagate the indexes existing in original tables. The
default is to not propagate them. Only applies to table objects.
</pre></div>
</div>
<p>Read on for a brief introduction to this utility.</p>
</div>
<div class="section" id="a-small-tutorial-on-ptrepack">
<h3>A small tutorial on ptrepack<a class="headerlink" href="#a-small-tutorial-on-ptrepack" title="Permalink to this headline">¶</a></h3>
<p>Imagine that we have ended the tutorial 1 (see the output of
examples/tutorial1-1.py), and we want to copy our reduced data (i.e. those
datasets that hangs from the /column group) to another file. First, let’s
remember the content of the examples/tutorial1.h5:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump tutorial1.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">'Test file'</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">'Pressure and Name'</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Name column selection'</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Pressure column selection'</span>
/detector <span class="o">(</span>Group<span class="o">)</span> <span class="s1">'Detector information'</span>
/detector/readout <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">))</span> <span class="s1">'Readout example'</span>
</pre></div>
</div>
<p>Now, copy the /columns to other non-existing file. That’s easy:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack tutorial1.h5:/columns reduced.h5
</pre></div>
</div>
<p>That’s all. Let’s see the contents of the newly created reduced.h5 file:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Name column selection'</span>
/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Pressure column selection'</span>
</pre></div>
</div>
<p>so, you have copied the children of /columns group into the <em>root</em> of the
reduced.h5 file.</p>
<p>Now, you suddenly realized that what you intended to do was to copy all the
hierarchy, the group /columns itself included. You can do that by just
specifying the destination group:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack tutorial1.h5:/columns reduced.h5:/columns
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Name column selection'</span>
/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Pressure column selection'</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">''</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Name column selection'</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Pressure column selection'</span>
</pre></div>
</div>
<p>OK. Much better. But you want to get rid of the existing nodes on the new
file. You can achieve this by adding the -o flag:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack -o tutorial1.h5:/columns reduced.h5:/columns
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">''</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Name column selection'</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Pressure column selection'</span>
</pre></div>
</div>
<p>where you can see how the old contents of the reduced.h5 file has been
overwritten.</p>
<p>You can copy just one single node in the repacking operation and change its
name in destination:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack tutorial1.h5:/detector/readout reduced.h5:/rawdata
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/rawdata <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">))</span> <span class="s1">'Readout example'</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">''</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Name column selection'</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Pressure column selection'</span>
</pre></div>
</div>
<p>where the /detector/readout has been copied to /rawdata in destination.</p>
<p>We can change the filter properties as well:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack --complevel<span class="o">=</span>1 tutorial1.h5:/detector/readout reduced.h5:/rawdata
Problems doing the copy from <span class="s1">'tutorial1.h5:/detector/readout'</span> to <span class="s1">'reduced.h5:/rawdata'</span>
The error was --> tables.exceptions.NodeError: destination group <span class="se">\`</span><span class="sb">`</span>/<span class="se">\`</span><span class="sb">`</span> already has a node named <span class="se">\`</span><span class="sb">`</span>rawdata<span class="sb">``</span>; you may want to use the <span class="se">\`</span><span class="sb">`</span>overwrite<span class="sb">``</span> argument
The destination file looks like:
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/rawdata <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">))</span> <span class="s1">'Readout example'</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">''</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Name column selection'</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Pressure column selection'</span>
Traceback <span class="o">(</span>most recent call last<span class="o">)</span>:
File <span class="s2">"utils/ptrepack"</span>, line 3, in ?
main<span class="o">()</span>
File <span class="s2">".../tables/scripts/ptrepack.py"</span>, line 349, in main
<span class="nv">stats</span> <span class="o">=</span> stats, <span class="nv">start</span> <span class="o">=</span> start, <span class="nv">stop</span> <span class="o">=</span> stop, <span class="nv">step</span> <span class="o">=</span> step<span class="o">)</span>
File <span class="s2">".../tables/scripts/ptrepack.py"</span>, line 107, in copy_leaf
raise RuntimeError, <span class="s2">"Please check that the node names are not</span>
<span class="s2"> duplicated in destination, and if so, add the --overwrite-nodes flag</span>
<span class="s2"> if desired."</span>
RuntimeError: Please check that the node names are not duplicated in
destination, and <span class="k">if </span>so, add the --overwrite-nodes flag <span class="k">if </span>desired.
</pre></div>
</div>
<p>Ooops! We ran into problems: we forgot that the /rawdata pathname already
existed in destination file. Let’s add the –overwrite-nodes, as the verbose
error suggested:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack --overwrite-nodes --complevel<span class="o">=</span>1 tutorial1.h5:/detector/readout
reduced.h5:/rawdata
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/rawdata <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'Readout example'</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">''</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Name column selection'</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Pressure column selection'</span>
</pre></div>
</div>
<p>you can check how the filter properties has been changed for the /rawdata
table. Check as the other nodes still exists.</p>
<p>Finally, let’s copy a <em>slice</em> of the readout table in origin to destination,
under a new group called /slices and with the name, for example, aslice:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>ptrepack -R1,8,3 tutorial1.h5:/detector/readout reduced.h5:/slices/aslice
<span class="nv">$ </span>ptdump reduced.h5
/ <span class="o">(</span>RootGroup<span class="o">)</span> <span class="s1">''</span>
/rawdata <span class="o">(</span>Table<span class="o">(</span>10,<span class="o">)</span>, shuffle, zlib<span class="o">(</span>1<span class="o">))</span> <span class="s1">'Readout example'</span>
/columns <span class="o">(</span>Group<span class="o">)</span> <span class="s1">''</span>
/columns/name <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Name column selection'</span>
/columns/pressure <span class="o">(</span>Array<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Pressure column selection'</span>
/slices <span class="o">(</span>Group<span class="o">)</span> <span class="s1">''</span>
/slices/aslice <span class="o">(</span>Table<span class="o">(</span>3,<span class="o">))</span> <span class="s1">'Readout example'</span>
</pre></div>
</div>
<p>note how only 3 rows of the original readout table has been copied to the new
aslice destination. Note as well how the previously nonexistent slices group
has been created in the same operation.</p>
</div>
</div>
<div class="section" id="pt2to3">
<h2>pt2to3<a class="headerlink" href="#pt2to3" title="Permalink to this headline">¶</a></h2>
<p>The PyTables 3.x series now follows <a class="reference external" href="http://www.python.org/dev/peps/pep-0008/">PEP 8</a> coding standard. This makes
using PyTables more idiomatic with surrounding Python code that also adheres
to this standard. The primary way that the 2.x series was <em>not</em> PEP 8
compliant was with respect to variable naming conventions. Approximately 450
API variables were identified and updated for PyTables 3.x.</p>
<p>To ease migration, PyTables ships with a new <tt class="docutils literal"><span class="pre">pt2to3</span></tt> command line tool.
This tool will run over a file and replace any instances of the old variable
names with the 3.x version of the name. This tool covers the overwhelming
majority of cases was used to transition the PyTables code base itself! However,
it may also accidentally also pick up variable names in 3rd party codes that
have <em>exactly</em> the same name as a PyTables’ variable. This is because <tt class="docutils literal"><span class="pre">pt2to3</span></tt>
was implemented using regular expressions rather than a fancier AST-based
method. By using regexes, <tt class="docutils literal"><span class="pre">pt2to3</span></tt> works on Python and Cython code.</p>
<p><tt class="docutils literal"><span class="pre">pt2to3</span></tt> <strong>help:</strong></p>
<div class="highlight-bash"><div class="highlight"><pre>usage: pt2to3 <span class="o">[</span>-h<span class="o">]</span> <span class="o">[</span>-r<span class="o">]</span> <span class="o">[</span>-p<span class="o">]</span> <span class="o">[</span>-o OUTPUT<span class="o">]</span> <span class="o">[</span>-i<span class="o">]</span> filename
PyTables 2.x -> 3.x API transition tool This tool displays to standard out, so
it is common to pipe this to another file: <span class="nv">$ </span>pt2to3 oldfile.py > newfile.py
positional arguments:
filename path to input file.
optional arguments:
-h, --help show this <span class="nb">help </span>message and <span class="nb">exit</span>
-r, --reverse reverts changes, going from 3.x -> 2.x.
-p, --no-ignore-previous
ignores previous_api<span class="o">()</span> calls.
-o OUTPUT output file to write to.
-i, --inplace overwrites the file in-place.
</pre></div>
</div>
<p>Note that <tt class="docutils literal"><span class="pre">pt2to3</span></tt> only works on a single file, not a a directory. However,
a simple BASH script may be written to run <tt class="docutils literal"><span class="pre">pt2to3</span></tt> over an entire directory
and all sub-directories:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="c">#!/bin/bash</span>
<span class="k">for </span>f in <span class="k">$(</span>find .<span class="k">)</span>
<span class="k">do</span>
<span class="k"> </span><span class="nb">echo</span> <span class="nv">$f</span>
pt2to3 <span class="nv">$f</span> > temp.txt
mv temp.txt <span class="nv">$f</span>
<span class="k">done</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><strong class="program">pt2to3</strong> uses the <tt class="xref py py-mod docutils literal"><span class="pre">argparse</span></tt> module that is part of the
Python standard library since Python 2.7.
Users of Python 2.6 should install <tt class="xref py py-mod docutils literal"><span class="pre">argparse</span></tt> separately
(e.g. via <strong class="program">pip</strong>).</p>
</div>
<p>The old APIs and variable names will continue to be supported for the short term,
where possible. (The major backwards incompatible changes come from the renaming
of some function and method arguments and keyword arguments.) Using the 2.x APIs
in the 3.x series, however, will issue warnings. The following is the release
plan for the warning types:</p>
<ul class="simple">
<li>3.0 - PendingDeprecationWarning</li>
<li>3.1 - DeprecationWarning</li>
<li>>=3.2 - Remove warnings, previous_api(), and _past.py; keep pt2to3,</li>
</ul>
<p>The current plan is to maintain the old APIs for at least 2 years, though this
is subject to change.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/logo-pytables-small.png" alt="Logo"/>
</a></p>
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Utilities</a><ul>
<li><a class="reference internal" href="#ptdump">ptdump</a><ul>
<li><a class="reference internal" href="#usage">Usage</a></li>
<li><a class="reference internal" href="#a-small-tutorial-on-ptdump">A small tutorial on ptdump</a></li>
</ul>
</li>
<li><a class="reference internal" href="#ptrepack">ptrepack</a><ul>
<li><a class="reference internal" href="#id1">Usage</a></li>
<li><a class="reference internal" href="#a-small-tutorial-on-ptrepack">A small tutorial on ptrepack</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pt2to3">pt2to3</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="parameter_files.html"
title="previous chapter">PyTables parameter files</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="file_format.html"
title="next chapter">PyTables File Format</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/usersguide/utilities.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="relbar-bottom">
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> </li>
<li class="right" >
<a href="../np-modindex.html" title="Python Module Index"
>modules</a> </li>
<li class="right" >
<a href="file_format.html" title="PyTables File Format"
>next</a> </li>
<li class="right" >
<a href="parameter_files.html" title="PyTables parameter files"
>previous</a> </li>
<li><a href="../index.html">PyTables 3.1.1 documentation</a> »</li>
<li><a href="index.html" >PyTables User’s Guide</a> »</li>
</ul>
</div>
</div>
<div class="footer">
© Copyright 2011-2014, PyTables maintainers.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
<!-- cloud_sptheme 1.3 -->
</body>
</html>
|