public void csvImport(String filename) {
        try {
            log.info("Importing from file \"{}\"", filename);
            int inserted = 0, updated = 0;
            db.beginTransaction();
            try (CSVReader reader = new CSVReader(new InputStreamReader(new FileInputStream(filename), "UTF-8"))) {
                String[] line = reader.readNext();
                log.debug("Parsing header: {}", Arrays.toString(line));
                parseHeader(line);

                while ((line = reader.readNext()) != null) {
                    Map<String, String> values = map(line);
                    Person p = db.getPerson(values.get("timestamp"));
                    if (p == null) {
                        db.insertPerson(values);
                        inserted++;
                    } else {
                        p.setPayment(values.get("payment"));
                        updated++;
                    }
                }
                if (confirm(inserted, updated)) {
                    db.commitTransaction();
                    log.info("Inserted {} and updated {} record(s) in the database.", inserted, updated);
                } else {
                    db.rollbackTransaction();
                    log.info("Import aborted by user. No data has been changed.");
                }
            } catch (IOException ioe) {
                log.error("Failed to read CSV file", ioe);
                db.rollbackTransaction();
                return;
            } catch (NoSuchElementException nsee) {
                log.error("Failed to parse CSV file header;", nsee);
                db.rollbackTransaction();
            }
        } catch (SQLException ex) {
            log.error("Database error during import: {}", ex);
            try {
                db.rollbackTransaction();
            } catch (SQLException e) {
                log.error("Failed to rollback transaction after failed import: ", e);
            }
        }
    }