<?xml version="1.0" encoding="windows-1252"?>
<node id="979799" title="Re^3: parse a line with varied number of fields" created="2012-07-03 18:30:18" updated="2012-07-03 18:30:18">
<type id="11">
note</type>
<author id="401112">
johngg</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;i&gt;preserves multiple spaces in the file name&lt;/i&gt;&lt;/blockquote&gt;
&lt;p&gt;In case others are puzzled let's share the enlightenment and explain what is going on. The reason spaces are preserved is that the file name field is never actually [doc://split]. First, the line is broken into nine fields.&lt;/p&gt;
&lt;code&gt;
1 2 3 4 5 6 7 8 file     name 10 11 12 13 14 15 16 17 18
^ ^ ^ ^ ^ ^ ^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
&lt;/code&gt;
&lt;p&gt;Then the last field from the first [doc://split] operation is reversed and broken into 10 fields.&lt;/p&gt;
&lt;code&gt;
81 71 61 51 41 31 21 11 01 eman     elif
^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^^^^^^^^^^^^
&lt;/code&gt;
&lt;p&gt;Finally the last field from the second [doc://split] operation is reversed to obtain the file name.&lt;/p&gt;
&lt;code&gt;
file     name
&lt;/code&gt;
&lt;p&gt;Note that spaces &lt;b&gt;in&lt;/b&gt; the file name will be preserved but if the file name has leading and/or trailing spaces the method fails as they will be lost.&lt;/p&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-401112"&gt;
&lt;p&gt;Cheers,&lt;/p&gt;&lt;p&gt;JohnGG&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
979570</field>
<field name="parent_node">
979757</field>
</data>
</node>
