[% INCLUDE 'help-top.inc' %]

<h1>CSV profiles</h1>

<p>CSV Profiles are created to define how you would like your cart or list to export.</p>

<h3>Add CSV Profiles</h3>

<p>To add a CSV Profile</p>

<ul>
	<li>Click 'CSV Profiles' from the Tools menu
<ul>
	<li>The 'Profile name' will appear on the export pull down list when choosing 'Download' from your cart or list</li>
    <li>The 'Profile description' is for your own benefit, but will also appear in the OPAC when patrons download content, so make sure it's clear to your patrons as well</li>
	<li>The 'CSV separator' is the character used to separate values and value groups</li>
    <li><strong>Tip:</strong> The most common option here is comma because most spreadsheet applications know how to open files split by commas.</li>
	<li>The 'Field separator' is the character used to separate duplicate fields
<ul>
    <li>Example: You may have multiple 650 fields and this is the character that will appear in between each one in the column</li>
</ul>
</li>
	<li>The 'Subfield separator' is the character used to separate duplicate subfields
<ul>
	<li>Example: You may have multiple $a subfields in a field</li>
</ul>
</li>
	<li>The 'Encoding' field lets you define the encoding used when saving the file</li>
    <li>Finally format your CSV file using the 'Profile MARC fields' fields
<ul>
    <li>Define which fields or subfields you want to export, separated by pipes. Example :200|210$a|301</li>
    <li><strong>Tip:</strong> You can also use your own headers (instead of the ones from Koha) by prefixing the field number with an header, followed by the equal sign. Example : Personal name=100|title=245$a|300</li>
</ul>
</li>
</ul>
</li>
</ul>

<p>When you have entered in all of the information for you profile, simply click 'Submit' and you will be presented with a confirmation that your profile has been saved.</p>

<h3>Modify CSV Profiles</h3>

<p>Once you have created at least one CSV Profile an 'Edit profile' tab will appear next to the 'New profile' button.</p>

<ul>
    <li>Choose the profile you would like to edit and alter the necessary fields.</li>
    <li>After submitting your changes you will be presented with a confirmation message at the top of the screen</li>
    <li>To delete a profile, check the 'Delete selected profile' option before clicking 'Submit Query'</li>
</ul>

<h3>Using CSV Profiles</h3>

<p>Your CSV Profiles will appear on the export list or cart menu under the 'Download' button in both the staff client and the OPAC</p>

<h3>Template Toolkit tags</h3>
[% TAGS [- -] %]
<p>You can use Template Toolkit tags in order to build complex CSV files.</p>
<p>To access to the field list of the current record, you have to use the 'fields' variables (which is a hashref).</p>
<p>All fields of the record is content into this variable in a "field tag name" key.</p>
<p>In order to manage multi-valuated field and subfields, the field and subfields are stored into an arrayref</p>
<p>For example, the following MARC record:</p>
<pre>
008 - FIXED-LENGTH DATA ELEMENTS--GENERAL INFORMATION
  @ 140211b xxu||||| |||| 00| 0 eng d

100 ## - MAIN ENTRY--PERSONAL NAME
  a Personal name My author

245 ## - TITLE STATEMENT
  a Title My first title
  a Title My second title
  b Remainder of title My remainder

245 ## - TITLE STATEMENT
  a Title My third title
</pre>
<p>will be stored into the following structure:</p>
<pre>
{
    fields =&gt; {
                008 =&gt; [
                        "140211b xxu||||| |||| 00| 0 eng d"
                ],
                100 =&gt; [
                            {
                                a =&gt; [
                                    "My author"
                                ]
                            }
                ]
                245 =&gt; [
                            {
                                a =&gt; [
                                    "My first title",
                                    "My second title"
                                ],
                                b =&gt; [
                                    "My remainder"
                                ]
                            },
                            {
                                a =&gt; [
                                    "My third title"
                                ]
                            }
                ]
    }
}
</pre>
<p>The indicators can be accessible using the 'indicator' key.</p>
<p>Example: [% fields.245.0.indicator.1 %] is the indicator 1 for the first 245 field.</p>

<p>Some examples:</p>
<ul>
  <li>Display all 245$a and 245$c into the same column:
    <p>
    [% FOREACH field IN fields.245 %]
        [% field.a.join(' ') %] [% field.c.join(' ') %]
    [% END %]
    </p>
  </li>
  <li>Display 650$a if indicator 2 for 650 is set
    <p>
    Subject=[% FOREACH field IN fields.650 %][% IF field.indicator.2 %][% field.a.0 %][% END %][% END %]
    </p>
  </li>
  <li>Display the language from the control field 008
    <p>
    Language=[% fields.008.0.substr( 28, 3 ) %]
    </p>
  </li>
  <li>Display the first subfield a for first field 245 if indicator 1 for field 100 is set
    <p>
    Title=[% IF fields.100.0.indicator.1 %][% fields.245.0.a.0 %][% END %]
    </p>
  </li>
</ul>
<p>Note that the authorized values won't be replaced by their descriptions.</p>
[- TAGS default -]

<p><strong>See the full documentation for CSV Profiles in the <a href="http://manual.koha-community.org/[% helpVersion %]/en/csvprofiles.html">manual</a> (online).</strong></p>

[% INCLUDE 'help-bottom.inc' %]
