summaryrefslogtreecommitdiffstats
path: root/bin/converter.pl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/converter.pl')
-rwxr-xr-xbin/converter.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/converter.pl b/bin/converter.pl
new file mode 100755
index 0000000..e1a2aa9
--- /dev/null
+++ b/bin/converter.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use strict 'vars';
+
+use DBI;
+
+my $dbfile = 'ksiazki.db';
+my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile", "", "");
+
+my($id,$isbn,$title,$author,$owner,$state,$who,$can_borrow,$reserved,$comment);
+
+
+open (INPUT,"ksiazki");
+
+my $_ = <INPUT>;
+
+while ($_)
+{
+ ($id,$isbn,$title,$author,$owner,$can_borrow) = split(/,/,$_);
+ chomp $can_borrow;
+ if($can_borrow eq 'Tak')
+ {
+ $can_borrow = 1;
+ }
+ else
+ {
+ $can_borrow = 0;
+ }
+ $dbh->do("insert into ksiazki values ($id,$isbn,'$title','$author','$owner',1,'nikt',$can_borrow,0,'')");
+ $_ = <INPUT>;
+}
+