Discussion:
[Koha] How to convert .csv file to .koc file
Sambhunath Sahoo
2018-08-30 11:49:19 UTC
Permalink
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 : ***@gmail.com,
***@tezu.ernet.in
*ORCID ID:* 0000-0001-9162-879X
*Researcher ID:* K-4446-2018
_______________________________________________
Koha mailing list http://koha-community.org
***@lists.katipo.co.
Owen Leonard
2018-08-30 13:15:27 UTC
Permalink
Post by Sambhunath Sahoo
I want to know the conversion procedure from .csv file to .koc file.
I don't know of an automated conversion process, but it's pretty easy
to manually convert a .csv to .koc. The .koc file is tab-separated
with a specific header line. For example:

Version=1.0 Generator=kocDesktop GeneratorVersion=1.3
2018-01-18 12-50-33 943 issue 1234567 30000000000001
2018-01-18 12-50-34 000 issue 1234567 30000000000002
2018-01-18 12-50-34 000 issue 1234567 30000000000003

The columns are: Transaction datetime - transaction type - patron card
number - item barcode

-- Owen
--
Web Developer
Athens County Public Libraries
https://www.myacpl.org
_______________________________________________
Koha mailing list http://koha-community.org
***@lists.katipo.co.nz
https://lists.katipo.co.nz/mailman/list
Chris Brown
2018-08-31 08:07:08 UTC
Permalink
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"
}
Post by Sambhunath Sahoo
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
*ORCID ID:* 0000-0001-9162-879X
*Researcher ID:* K-4446-2018
_______________________________________________
Koha mailing list http://koha-community.org
https://lists.katipo.co.nz/mailman/listinfo/koha
_______________________________________________
Koha mailing list http://koha-community.org
***@lists.katipo.co
Zeki Celikbas
2018-08-31 13:33:49 UTC
Permalink
Here is a simple solution in terminal:

|sed 's/,/\t/g' input_file > output_file |

This command replace all comma characters to TAB from input_file and
write out a file named output_file. Don't wory to test because it writes
a seperate file.
Post by Sambhunath Sahoo
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
*ORCID ID:* 0000-0001-9162-879X
*Researcher ID:* K-4446-2018
_______________________________________________
Koha mailing list http://koha-community.org
https://lists.katipo.co.nz/mailman/listinfo/koha
_______________________________________________
Koha mailing list http://koha-community.org
***@lists.katipo.co.

Loading...