{"id":16884738,"url":"https://github.com/timwis/beacon-data-importer","last_synced_at":"2026-05-17T22:37:07.002Z","repository":{"id":52706483,"uuid":"252511613","full_name":"timwis/beacon-data-importer","owner":"timwis","description":"Convert person data to a CSV format that can easily be imported to Beacon's database","archived":false,"fork":false,"pushed_at":"2021-04-20T16:48:21.000Z","size":56,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-25T07:11:55.546Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timwis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-02T16:41:04.000Z","updated_at":"2023-03-04T04:39:04.000Z","dependencies_parsed_at":"2022-08-22T07:40:47.000Z","dependency_job_id":null,"html_url":"https://github.com/timwis/beacon-data-importer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timwis%2Fbeacon-data-importer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timwis%2Fbeacon-data-importer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timwis%2Fbeacon-data-importer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timwis%2Fbeacon-data-importer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timwis","download_url":"https://codeload.github.com/timwis/beacon-data-importer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244560387,"owners_count":20472218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T16:30:10.802Z","updated_at":"2026-05-17T22:37:01.975Z","avatar_url":"https://github.com/timwis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Beacon data importer\nConvert person data to a CSV format that can easily be imported\nto Beacon's database.\n\n## Installation\n\nEnsure you have Python 3.7+ installed on your machine.\n\n```\npip3 install \"git+https://github.com/timwis/beacon-data-importer#egg=beacon-data-importer\"\n```\n\n## Usage\n\n```bash\nUsage: beacon [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n  --help  Show this message and exit.\n\nCommands:\n  prepare-calls     Prepares call log records for import into a temporary...\n  prepare-contacts  Extracts core contact fields from gds_file_path, and...\n```\n\n\u003e Tip: To preview the data, pass it to [csvlook][csvlook] and less:\n\u003e\n\u003e ```\n\u003e beacon \u003ccmd\u003e \u003cfile\u003e | csvlook --no-inference | less --chop-long-lines\n\u003e # aka:\n\u003e beacon \u003ccmd\u003e \u003cfile\u003e | csvlook -I | less -S\n\u003e ```\n\n## Authentication\n\nWe'll use the heroku CLI to interact with the database. Login to heroku by copying the URL from the following command into your browser.\n\n```bash\nheroku auth:login\n```\n\n## Contacts\n\nPrepare the data for import using the `beacon` CLI tool.\n\n```bash\nbeacon prepare-contacts gds.csv healthintent.csv \u003e contacts.csv\n```\n\nLoad `contacts.csv` into the `contacts` table, which should already be created by the application's migrations.\n\n```bash\nheroku pg:psql --app \u003capp-name\u003e --command \"\\COPY contacts (nhs_number, first_name, middle_names, surname, address, postcode, telephone, mobile, date_of_birth, created_at, updated_at, gds_import_data) FROM contacts.csv DELIMITER ',' CSV HEADER\"\n```\n\n## Call logs\n\nPrepare the data for import using the `beacon` CLI tool.\n\n```bash\nbeacon prepare-calls --food-needs-user USER --complex-needs-user USER --simple-needs-user USER --output-dir ./output calls.csv\n```\n\nCreate the temporary loading tables.\n\n```bash\nheroku pg:psql --app \u003capp-name\u003e --file sql/create_tmp_tables.sql\n```\n\nLoad prepared files into the temporary loading tables.\n\n```bash\nheroku pg:psql --app \u003capp-name\u003e --command \"\\COPY tmp_original_triage_needs (nhs_number, category, name, created_at, updated_at, completed_on) FROM original_triage_needs.csv DELIMITER ',' CSV HEADER\"\nheroku pg:psql --app \u003capp-name\u003e --command \"\\COPY tmp_original_triage_notes (nhs_number, category, body, created_at, updated_at, import_data) FROM original_triage_notes.csv DELIMITER ',' CSV HEADER\"\nheroku pg:psql --app \u003capp-name\u003e --command \"\\COPY tmp_identified_needs (nhs_number, category, name, created_at, updated_at, completed_on, supplemental_data, user_id) FROM food_needs.csv DELIMITER ',' CSV HEADER\"\nheroku pg:psql --app \u003capp-name\u003e --command \"\\COPY tmp_identified_needs (nhs_number, category, name, created_at, updated_at, start_on) FROM callback_needs.csv DELIMITER ',' CSV HEADER\"\nheroku pg:psql --app \u003capp-name\u003e --command \"\\COPY tmp_identified_needs (nhs_number, category, name, created_at, updated_at, user_id) FROM remaining_needs.csv DELIMITER ',' CSV HEADER\"\nheroku pg:psql --app \u003capp-name\u003e --command \"\\COPY tmp_contact_profile_updates (nhs_number, additional_info, delivery_details, dietary_details, has_covid_symptoms) FROM contact_profile_updates.csv DELIMITER ',' CSV HEADER\"\n```\n\nYou can verify it's been loaded in via the psql tool. Use `\\q` to quit.\n\n\u003e Note: run export PAGER=\"less -S\" first to support horizontal scrolling.\n\n```bash\nheroku pg:psql --app \u003capp-name\u003e\n=\u003e select * from tmp_original_triage_needs;\n```\n\nImport the data from the temporary loading tables into the application tables.\n\n```bash\nheroku pg:psql --app \u003capp-name\u003e --file sql/import_original_triage_needs_and_notes.sql\nheroku pg:psql --app \u003capp-name\u003e --file sql/import_identified_needs.sql\nheroku pg:psql --app \u003capp-name\u003e --file sql/import_contact_profile_updates.sql\n```\n\nRemove the temporary calls table you created.\n\n```bash\nheroku pg:psql --app \u003capp-name\u003e --command \"DROP TABLE tmp_original_triage_needs, tmp_original_triage_notes, tmp_identified_needs, tmp_contact_profile_updates\"\n```\n\n[csvlook]: https://csvkit.readthedocs.io/en/latest/scripts/csvlook.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimwis%2Fbeacon-data-importer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimwis%2Fbeacon-data-importer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimwis%2Fbeacon-data-importer/lists"}