[Koha] How to convert .csv file to .koc file

Chris Brown chris at stayawake.co.uk
Fri Aug 31 20:07:08 NZST 2018


Dear  Sambhunath,

The .koc file is a simple tab-separated format so converting from CSV is
likely to be just a matter of re-ordering the fields and maybe tweaking the
format. I used an "awk" script for this, because it's a little language I
know fairly well, but you could use Python or PHP or a shell script. Here's
my awk code in case it helps; of course it almost certainly won't work for
you without adjustment.

Hope this helps,

Best Regards,

Chris Brown

======
# awk script to convert "issues" data from yellow sticker CSV
# to Koha Offline Circulation file format

# Input format:
# Book ID, Customer ID, Check-Out Date M/DD/YYYY
# 1353,78574,3/30/2016, ... other fields

# Output format
# 2016-03-30 12:00:00 000 <TAB> issue <TAB> 78574 <TAB> 1353
# The spreadsheet only records the date of issue not HH:MM:SS
# so those are set to dummy values.

BEGIN { FS=","
             OFS="\t"
             print "Version=1.0"  # .koc header line
           }
{ print fix_date($3), "issue", $2, $1 }

function fix_date(d) {
    split(d, s, "/")
    # Add a leading zero to the month if necessary
    if (length(s[1]) == 1)
        s[1] = "0" s[1]
    # Add a leading zero to the day if necessary
    if (length(s[2]) == 1)
        s[2] = "0" s[2]
    return s[3] "-" s[1] "-" s[2] " 12:00:00 000"
}


On Thu, Aug 30, 2018 at 12:49 PM Sambhunath Sahoo <sambhumlis at gmail.com>
wrote:

> Dear friends,
>
> I want to know the conversion procedure from .csv file to .koc file. If
> anybody has done this kind of conversion for Koha, please suggest me the
> procedure.
>
> Regards,
>
> Sambhunath Sahoo
> Information Scientist,
> Central Library,
> Tezpur University,
> Tezpur-784028
> Assam
> Mobile: 9085252152, 8895488636
> Phone : 03712-27-3229
> E-Mail : sambhumlis at gmail.com,
>             sambhu at tezu.ernet.in
> *ORCID ID:* 0000-0001-9162-879X
> *Researcher ID:* K-4446-2018
> _______________________________________________
> Koha mailing list  http://koha-community.org
> Koha at lists.katipo.co.nz
> https://lists.katipo.co.nz/mailman/listinfo/koha
>


More information about the Koha mailing list