{"id":38,"date":"2009-06-04T11:54:03","date_gmt":"2009-06-04T15:54:03","guid":{"rendered":"http:\/\/ewart.homelinux.net\/?p=38"},"modified":"2010-08-14T12:52:34","modified_gmt":"2010-08-14T16:52:34","slug":"converting-the-dbtext-borrower-database","status":"publish","type":"post","link":"https:\/\/www.bobsown.net\/?p=38","title":{"rendered":"Converting the DBText Borrower Database"},"content":{"rendered":"<p>The DBText borrower database needs to be converted into a comma delimited file in the proper format to be loaded into Koha via Import Patrons in the Tools menu.  Most of the fields can be mapped into the corresponding Koha fields.  The branch code and an initial password need to be added.  We have added a number of fields to DBText that will be needed by Koha.<\/p>\n<p>DBTextMembers is patterned after DBTextCheck.\u00a0 It can be downloaded <a title=\"DBTextMember\" href=\"wp-content\/uploads\/koha\/DBTextMembers\" target=\"_blank\">here.<\/a> It does some formatting checks on phone numbers and dates.<\/p>\n<p><!--more--><\/p>\n<p><strong>Conversion Steps<\/strong><\/p>\n<ol>\n<li>Modify the code.\u00a0 In addition to the @check_blank array of fields, you will need to go through the code to select and format the output fields.\u00a0 See the program details below.<\/li>\n<li>Run DBTextMember on the exported borrower file.\u00a0 The output defaults to <em>patron.csv<\/em>.<\/li>\n<li>Take a look at <em>paterr.csv<\/em>.\u00a0 It will have some additional errors found in formatting the output.\u00a0 You may want to go back to DBText, fix them, and re-run step 2.<\/li>\n<li>Go to the Tools menu in Koha and click on Import Patrons.\u00a0 It will ask you for the file to be imported.<\/li>\n<li>This may also find some errors which you will want to fix.<\/li>\n<\/ol>\n<p><strong>Field Mapping<\/strong><\/p>\n<table border=\"0\">\n<tbody>\n<tr>\n<th>DBText<\/th>\n<th>Koha<\/th>\n<th>Processing<\/th>\n<\/tr>\n<tr>\n<td>Borrower Number<\/td>\n<td>borrowernumber<br \/>\ncardnumber<br \/>\nuserid<\/td>\n<td>set_field<\/td>\n<\/tr>\n<tr>\n<td>Last Name<\/td>\n<td>surname<\/td>\n<td>use Company if blank, comma or period<\/td>\n<\/tr>\n<tr>\n<td>First Name<\/td>\n<td>firstname<\/td>\n<td>set_field<\/td>\n<\/tr>\n<tr>\n<td>Address<\/td>\n<td>address<\/td>\n<td>set_field<\/td>\n<\/tr>\n<tr>\n<td>Company<\/td>\n<td>address2<\/td>\n<td>set_field<\/td>\n<\/tr>\n<tr>\n<td>City<br \/>\nState<br \/>\nCountry<\/td>\n<td>city<\/td>\n<td>include country if not USA or blank<\/td>\n<\/tr>\n<tr>\n<td>Zip<\/td>\n<td>zipcode<\/td>\n<td>set_field use 33300 as default<\/td>\n<\/tr>\n<tr>\n<td>EMail<\/td>\n<td>email<\/td>\n<td>set_field<\/td>\n<\/tr>\n<tr>\n<td>Phone<\/td>\n<td>phone<\/td>\n<td>set_phone<\/td>\n<\/tr>\n<tr>\n<td>Cell Phone<\/td>\n<td>mobile<\/td>\n<td>set_phone<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>branchcode<\/td>\n<td>SLA<\/td>\n<\/tr>\n<tr>\n<td>Record Created<\/td>\n<td>dateenrolled<\/td>\n<td>set_date<\/td>\n<\/tr>\n<tr>\n<td>ExpirationDate<\/td>\n<td>dateexpiry<\/td>\n<td>set_date<\/td>\n<\/tr>\n<tr>\n<td>Notes<\/td>\n<td>borrowernotes<\/td>\n<td>set_field<\/td>\n<\/tr>\n<tr>\n<td>Zipcode<\/td>\n<td>password<\/td>\n<td>first 5 characters<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Patron Attributes<\/strong><\/p>\n<p>If <em>MailingList<\/em> is set, MAIL is set to True or False as appropriate.\u00a0 PUBLISH is set similarly.<\/p>\n<p>The SELECT attributes will be set with BOD, BUS, FAM, IND, CULT and PR.\u00a0 All other <em>Select Codes<\/em> will be dropped.<\/p>\n<p><strong>Patron Category<\/strong><\/p>\n<p>The patron category is set with FAM, IND, BUS or PR in that order, if one of those codes is present in <em>Select Codes. <\/em>If none of those are present and there is an expiration date, the category is set to IND.\u00a0 If all else fails, the category is OTHER.<\/p>\n<p><strong>Program Description<\/strong><\/p>\n<p>DBTextMembers is written in Perl.\u00a0 Time::Local, Getopt::Long and Date::Manip are required Perl modules.<\/p>\n<p>The first part of the program reads in the first record to set up the field names and number, very much as DBTextCheck did.\u00a0 It opens two output files which default to <em>patron.csv<\/em> and <em>paterr.csv<\/em>.\u00a0 The name of the input file is the required parameter.\u00a0 The error file contains the borrower number, name and a list of errors for each record with errors.<\/p>\n<p>The main loop reads in each record and cleans up the fields.\u00a0 The record is checked to see if it is blank.\u00a0 Then the fields are mapped as shown in the table above and the patron attributes are set.\u00a0 The patron category is set last because it depends on some of the previous fields. The record is formatted as comma delimited values and writen out.<\/p>\n<p>At the end of the program, various statistics are written out to the console.<\/p>\n<p><strong>Subroutines<\/strong><\/p>\n<ul>\n<li><strong>set_phone:<\/strong> This routine looks for 3 digits, 3 digits, 4 digits followed by anything.\u00a0 The digits may be separated by any non-digits. So <em>954-123-4567 ext 123<\/em><strong> <\/strong>or 9541234567 would be valid phone numbers.\u00a0 If it can&#8217;t find that pattern, it looks for 3 digits and 4 digits followed by anything.\u00a0 In that case, it has to guess at the area code.\u00a0 If the zip code starts with 334, it is in Palm Beach County and should have 561 as the area code.\u00a0 A zip of 334.. is Miami-Dade county with area code 305.\u00a0 Anything else is 954.\u00a0 We hope that any member outside the three county area has an area code.\n<p>Two parameters are required: the input field name and the output field name.<\/li>\n<li><strong>set_date: <\/strong>This routine tries to format the date to mm\/dd\/yyyy with leading zeros.\u00a0 One of the errors that occurs is having the day of the month set to 31 in a month that has less than 31 days.\u00a0 In that case, the day of the month is set to 28.\u00a0 If the date is still invalid or missing, it is set to the default date, $dfltDate = &#8217;02\/05\/2002&#8242;.\u00a0 The default is the date that we started using DBText.\u00a0 It is necessary to specify dates rather than let Koha assign one.\n<p>Two parameters are required: the input field name and the output field name.<\/li>\n<li><strong>set_field:<\/strong> This routine gets the input field.\u00a0 Single quotes (&#8216;) are doubled (&#8221; that&#8217;s 2 characters) to conform with comma-separated-values standards.\u00a0 If the field contains commas or double quotes (&#8221; that&#8217;s one character), it is enclosed with double quotes.\n<p>Two parameters are required: the input field name and the output field name.\u00a0 A third parameter may be used to set a default value when the input field is missing.\u00a0 In that case and error will be noted.<\/li>\n<li><strong>put_error:<\/strong> This routine collects errors and writes them to <em>paterr.csv.<\/em> The first output field contains the borrower number.\u00a0 If it is different from the current borrower number, the record is written out.\u00a0 The second output field contains the borrower or company name.\u00a0 The third output field contains a list of errors.\n<p>One parameter is required: the error description, usually the name of the input field.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The DBText borrower database needs to be converted into a comma delimited file in the proper format to be loaded into Koha via Import Patrons in the Tools menu. Most of the fields can be mapped into the corresponding Koha &hellip; <a href=\"https:\/\/www.bobsown.net\/?p=38\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[16],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-conversion-to-koha"],"_links":{"self":[{"href":"https:\/\/www.bobsown.net\/index.php?rest_route=\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bobsown.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bobsown.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bobsown.net\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bobsown.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=38"}],"version-history":[{"count":1,"href":"https:\/\/www.bobsown.net\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":198,"href":"https:\/\/www.bobsown.net\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions\/198"}],"wp:attachment":[{"href":"https:\/\/www.bobsown.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bobsown.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bobsown.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}