How to convert .csv file to .koc file
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@gmail.com, sambhu@tezu.ernet.in *ORCID ID:* 0000-0001-9162-879X *Researcher ID:* K-4446-2018
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
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@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@gmail.com, sambhu@tezu.ernet.in *ORCID ID:* 0000-0001-9162-879X *Researcher ID:* K-4446-2018 _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha
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. 30-08-2018 14:49 tarihinde Sambhunath Sahoo yazdı:
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@gmail.com, sambhu@tezu.ernet.in *ORCID ID:* 0000-0001-9162-879X *Researcher ID:* K-4446-2018 _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha
participants (4)
-
Chris Brown -
Owen Leonard -
Sambhunath Sahoo -
Zeki Celikbas