Skip to content

Instantly share code, notes, and snippets.

@tdussa
Last active April 20, 2024 17:21
Show Gist options
  • Save tdussa/750e134913989ca51107469c974345a0 to your computer and use it in GitHub Desktop.
Save tdussa/750e134913989ca51107469c974345a0 to your computer and use it in GitHub Desktop.
Vaccination Status Overview script for VisiData

This VisiData script is meant to take a number of CSV files containing vaccination information and mangle the data to create a nice overview.

The input data is expected in the format seen in the sample files.

To use, just load it with vd -p Vaccination_Status_Overview.vd; to add or remove persons, the script itself needs to be edited.

Update: Refactoring so that the duration until the next refresher shot is calculated and displayed. An additional column in the data files is needed that contains the time to the next refresher in weeks; if that column is empty, that vaccination shot is assumed to be final without any more required refreshers.

We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 3 columns, instead of 2. in line 1.
Date, Vaccination, RefreshTarget
1977-05-10, Tuberculosis
1977-08-09, Diphtheria
1977-08-09, Tetanus, 520
1977-10-26, Diphtheria
1977-10-26, Tetanus
1977-11-24, Poliomyelitis
1978-01-27, Poliomyelitis
1978-05-10, Diphtheria
1978-05-10, Tetanus
1978-10-17, Measels
1978-10-17, Mumps
1979-05-11, Poliomyelitis
1983-07-29, Diphtheria
1983-07-29, Tetanus
1987-11-11, Poliomyelitis
1993-06-18, Diphtheria
1993-06-18, Tetanus
1993-08-13, Measels
1996-09-03, Diphtheria
1996-09-03, Tetanus
1996-09-03, Poliomyelitis
1999-05-03, TBE
1999-07-28, TBE
2000-06-08, TBE
2005-10-24, Diphtheria
2005-10-24, Tetanus
2005-10-27, Hepatitis A
2005-10-27, Hepatitis B
2005-11-29, Hepatitis A
2005-11-29, Hepatitis B
2006-06-23, TBE
2006-06-23, Hepatitis A
2006-06-23, Hepatitis B
2007-07-06, TBE
2007-08-06, TBE
2010-08-11, TBE
2015-05-19, Diphtheria, 530
2015-05-19, Pertussis, 530
2015-05-19, Poliomyelitis, 530
2015-05-19, Tetanus, 530
2015-06-10, TBE, 260
2015-06-10, Hepatitis B, 530
2021-04-30, SARS-CoV-2, 6
2021-06-11, SARS-CoV-2, 26
2021-11-12, Influenza, 53
2021-11-25, SARS-CoV-2, 26
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 3 columns, instead of 2. in line 2.
Date, Vaccination, RefreshTarget
2021-11-25, SARS-CoV-2, 52
2021-06-09, SARS-CoV-2
2021-04-28, SARS-CoV-2
2021-01-06, TBE
2017-05-22, Tetanus
2017-05-22, Diphtheria
2000-02-15, Hepatitis B
2000-02-15, Hepatitis A
1999-07-19, Typhoid fever
1999-07-19, Tetanus
1999-07-19, Poliomyelitis
1999-07-19, Hepatitis B
1999-07-19, Hepatitis A
1999-07-19, Diphtheria
1999-06-24, Hepatitis B
1999-06-24, Hepatitis A
1999-06-24, Yellow fever
1986-11-25, Poliomyelitis
1986-11-25, Diphtheria
1986-10-11, Tetanus
1981-04-10, Tetanus
1978-08-24, Tetanus
1978-08-24, Measels
1978-08-24, Diphtheria
1977-12-06, Poliomyelitis
1977-04-25, Tetanus
1977-04-25, Poliomyelitis
1977-04-25, Diphtheria
1977-03-11, Tetanus
1977-03-11, Poliomyelitis
1977-03-11, Diphtheria
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 3 columns, instead of 2. in line 1.
Date, Vaccination, RefreshTarget
2007-04-26, Diphtheria
2007-04-26, Haemophilus influenzae b
2007-04-26, Pertussis
2007-04-26, Pneumococcus
2007-04-26, Poliomyelitis
2007-04-26, Tetanus
2007-06-11, Diphtheria
2007-06-11, Haemophilus influenzae b
2007-06-11, Pertussis
2007-06-11, Pneumococcus
2007-06-11, Poliomyelitis
2007-06-11, Tetanus
2007-07-19, Diphtheria
2007-07-19, Haemophilus influenzae b
2007-07-19, Pertussis
2007-07-19, Pneumococcus
2007-07-19, Poliomyelitis
2007-07-19, Tetanus
2008-04-08, Diphtheria
2008-04-08, Haemophilus influenzae b
2008-04-08, Pertussis
2008-04-08, Pneumococcus
2008-04-08, Poliomyelitis
2008-04-08, Tetanus
2008-05-30, Measels
2008-05-30, Mumps
2008-05-30, Rubella
2009-12-15, Meningococcus
2013-01-04, Diphtheria
2013-01-04, Measels
2013-01-04, Mumps
2013-01-04, Pertussis
2013-01-04, Rubella
2013-01-04, Tetanus
2015-09-11, TBE
2017-09-05, TBE
2017-09-05, HPV
2018-05-15, Poliomyelitis
2018-09-15, HPV
2019-12-04, TBE
2019-12-04, Hepatitis A
2019-12-04, Hepatitis B
2020-07-07, Hepatitis A
2020-07-07, Hepatitis B
2021-06-08, SARS-CoV-2
2021-07-07, SARS-CoV-2
2021-12-08, Hepatitis A
2021-12-08, Hepatitis B
2021-12-30, SARS-CoV-2
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 3 columns, instead of 2. in line 1.
Date, Vaccination, RefreshTarget
2010-11-05, Diphtheria
2010-11-05, Haemophilus influenzae b
2010-11-05, Pertussis
2010-11-05, Pneumococcus
2010-11-05, Poliomyelitis
2010-11-05, Tetanus
2011-01-07, Diphtheria
2011-01-07, Haemophilus influenzae b
2011-01-07, Pertussis
2011-01-07, Pneumococcus
2011-01-07, Poliomyelitis
2011-01-07, Tetanus
2011-03-11, Diphtheria
2011-03-11, Haemophilus influenzae b
2011-03-11, Pertussis
2011-03-11, Pneumococcus
2011-03-11, Poliomyelitis
2011-03-11, Tetanus
2011-07-22, Meningococcus
2011-09-29, Measels
2011-09-29, Mumps
2011-09-29, Rubella
2012-08-28, Diphtheria
2012-08-28, Haemophilus influenzae b
2012-08-28, Pertussis
2012-08-28, Pneumococcus
2012-08-28, Poliomyelitis
2012-08-28, Tetanus
2013-01-04, Measels
2013-01-04, Mumps
2013-01-04, Rubella
2017-09-05, TBE
2017-12-22, Diphtheria
2017-12-22, TBE
2017-12-22, Pertussis
2017-12-22, Tetanus
2019-12-04, TBE
2020-07-07, Hepatitis A
2020-07-07, Hepatitis B
2021-12-18, SARS-CoV-2
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 3 columns, instead of 2. in line 1.
Date, Vaccination, RefreshTarget
2014-08-22, Diphtheria
2014-08-22, Haemophilus influenzae b
2014-08-22, Hepatitis B
2014-08-22, Pertussis
2014-08-22, Pneumococcus
2014-08-22, Poliomyelitis
2014-08-22, Tetanus
2014-09-26, Diphtheria
2014-09-26, Haemophilus influenzae b
2014-09-26, Hepatitis B
2014-09-26, Pertussis
2014-09-26, Pneumococcus
2014-09-26, Poliomyelitis
2014-09-26, Tetanus
2015-01-07, Diphtheria
2015-01-07, Haemophilus influenzae b
2015-01-07, Hepatitis B
2015-01-07, Pertussis
2015-01-07, Pneumococcus
2015-01-07, Poliomyelitis
2015-01-07, Tetanus
2015-04-17, Measels
2015-04-17, Mumps
2015-04-17, Rubella
2015-04-17, Chickenpox
2015-05-21, Meningococcus
2015-07-10, Diphtheria
2015-07-10, Haemophilus influenzae b
2015-07-10, Hepatitis B
2015-07-10, Pertussis
2015-07-10, Pneumococcus
2015-07-10, Poliomyelitis
2015-07-10, Tetanus
2015-09-25, Measels
2015-09-25, Mumps
2015-09-25, Rubella
2015-09-25, Chickenpox
2019-08-12, TBE
2019-12-04, TBE
2020-09-08, Diphtheria
2020-09-08, TBE
2020-09-08, Pertussis
2020-09-08, Tetanus
sheet col row longname input keystrokes comment
import-python datetime import Python module in the global scope
open-file Person_A.csv o
rename-sheet Vaccinations Person A Rename current sheet
Vaccinations Person A Vaccination key-col ! toggle current column as a key column
Vaccinations Person A Date sort-desc ] sort descending by current column; replace any existing sort criteria
Vaccinations Person A Date aggregate-col max + Add aggregator to current column
Vaccinations Person A Date aggregate-col list + Add aggregator to current column
Vaccinations Person A RefreshTarget type-int # set type of current column to int
Vaccinations Person A RefreshTarget addcol-expr str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' = create new column from Python expression, with column names as variables
Vaccinations Person A str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' rename-col Refresh ^ rename current column
Vaccinations Person A Refresh aggregate-col max + Add aggregator to current column
Vaccinations Person A resize-cols-max g_ resize all cols to max
Vaccinations Person A Vaccination freq-col Shift+F open Frequency Table grouped on current column, with aggregations of other columns
rename-sheet Vaccination Status Person A Rename current sheet
Vaccination Status Person A Vaccination addcol-expr f', '.join(map(str, Date_list)) = create new column from Python expression, with column names as variables
Vaccination Status Person A f', '.join(map(str, Date_list)) rename-col Vaccinations ^ edit name of current column
Vaccination Status Person A Vaccination addcol-expr f'{Refresh_max} (#{count}: {Date_max})' = create new column from Python expression, with column names as variables
Vaccination Status Person A f'{Refresh_max} (#{count}: {Date_max})' rename-col Refresh ^ edit name of current column
Vaccination Status Person A count hide-col - Hide current column
Vaccination Status Person A Date_max hide-col - Hide current column
Vaccination Status Person A Date_list hide-col - Hide current column
Vaccination Status Person A Refresh_max hide-col - Hide current column
Vaccination Status Person A Vaccination sort-asc [ sort ascending by current column; replace any existing sort criteria
Vaccination Status Person A resize-cols-max g_ resize all cols to max
open-file Person_B.csv o
rename-sheet Vaccinations Person B Rename current sheet
Vaccinations Person B Vaccination key-col ! toggle current column as a key column
Vaccinations Person B Date sort-desc ] sort descending by current column; replace any existing sort criteria
Vaccinations Person B Date aggregate-col max + Add aggregator to current column
Vaccinations Person B Date aggregate-col list + Add aggregator to current column
Vaccinations Person B RefreshTarget type-int # set type of current column to int
Vaccinations Person B RefreshTarget addcol-expr str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' = create new column from Python expression, with column names as variables
Vaccinations Person B str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' rename-col Refresh ^ rename current column
Vaccinations Person B Refresh aggregate-col max + Add aggregator to current column
Vaccinations Person B resize-cols-max g_ resize all cols to max
Vaccinations Person B Vaccination freq-col Shift+F open Frequency Table grouped on current column, with aggregations of other columns
rename-sheet Vaccination Status Person B Rename current sheet
Vaccination Status Person B Vaccination addcol-expr f', '.join(map(str, Date_list)) = create new column from Python expression, with column names as variables
Vaccination Status Person B f', '.join(map(str, Date_list)) rename-col Vaccinations ^ edit name of current column
Vaccination Status Person B Vaccination addcol-expr f'{Refresh_max} (#{count}: {Date_max})' = create new column from Python expression, with column names as variables
Vaccination Status Person B f'{Refresh_max} (#{count}: {Date_max})' rename-col Refresh ^ edit name of current column
Vaccination Status Person B count hide-col - Hide current column
Vaccination Status Person B Date_max hide-col - Hide current column
Vaccination Status Person B Date_list hide-col - Hide current column
Vaccination Status Person B Refresh_max hide-col - Hide current column
Vaccination Status Person B Vaccination sort-asc [ sort ascending by current column; replace any existing sort criteria
Vaccination Status Person B resize-cols-max g_ resize all cols to max
open-file Person_C.csv o
rename-sheet Vaccinations Person C Rename current sheet
Vaccinations Person C Vaccination key-col ! toggle current column as a key column
Vaccinations Person C Date sort-desc ] sort descending by current column; replace any existing sort criteria
Vaccinations Person C Date aggregate-col max + Add aggregator to current column
Vaccinations Person C Date aggregate-col list + Add aggregator to current column
Vaccinations Person C RefreshTarget type-int # set type of current column to int
Vaccinations Person C RefreshTarget addcol-expr str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' = create new column from Python expression, with column names as variables
Vaccinations Person C str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' rename-col Refresh ^ rename current column
Vaccinations Person C Refresh aggregate-col max + Add aggregator to current column
Vaccinations Person C resize-cols-max g_ resize all cols to max
Vaccinations Person C Vaccination freq-col Shift+F open Frequency Table grouped on current column, with aggregations of other columns
rename-sheet Vaccination Status Person C Rename current sheet
Vaccination Status Person C Vaccination addcol-expr f', '.join(map(str, Date_list)) = create new column from Python expression, with column names as variables
Vaccination Status Person C f', '.join(map(str, Date_list)) rename-col Vaccinations ^ edit name of current column
Vaccination Status Person C Vaccination addcol-expr f'{Refresh_max} (#{count}: {Date_max})' = create new column from Python expression, with column names as variables
Vaccination Status Person C f'{Refresh_max} (#{count}: {Date_max})' rename-col Refresh ^ edit name of current column
Vaccination Status Person C count hide-col - Hide current column
Vaccination Status Person C Date_max hide-col - Hide current column
Vaccination Status Person C Date_list hide-col - Hide current column
Vaccination Status Person C Refresh_max hide-col - Hide current column
Vaccination Status Person C Vaccination sort-asc [ sort ascending by current column; replace any existing sort criteria
Vaccination Status Person C resize-cols-max g_ resize all cols to max
open-file Person_D.csv o
rename-sheet Vaccinations Person D Rename current sheet
Vaccinations Person D Vaccination key-col ! toggle current column as a key column
Vaccinations Person D Date sort-desc ] sort descending by current column; replace any existing sort criteria
Vaccinations Person D Date aggregate-col max + Add aggregator to current column
Vaccinations Person D Date aggregate-col list + Add aggregator to current column
Vaccinations Person D RefreshTarget type-int # set type of current column to int
Vaccinations Person D RefreshTarget addcol-expr str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' = create new column from Python expression, with column names as variables
Vaccinations Person D str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' rename-col Refresh ^ rename current column
Vaccinations Person D Refresh aggregate-col max + Add aggregator to current column
Vaccinations Person D resize-cols-max g_ resize all cols to max
Vaccinations Person D Vaccination freq-col Shift+F open Frequency Table grouped on current column, with aggregations of other columns
rename-sheet Vaccination Status Person D Rename current sheet
Vaccination Status Person D Vaccination addcol-expr f', '.join(map(str, Date_list)) = create new column from Python expression, with column names as variables
Vaccination Status Person D f', '.join(map(str, Date_list)) rename-col Vaccinations ^ edit name of current column
Vaccination Status Person D Vaccination addcol-expr f'{Refresh_max} (#{count}: {Date_max})' = create new column from Python expression, with column names as variables
Vaccination Status Person D f'{Refresh_max} (#{count}: {Date_max})' rename-col Refresh ^ edit name of current column
Vaccination Status Person D count hide-col - Hide current column
Vaccination Status Person D Date_max hide-col - Hide current column
Vaccination Status Person D Date_list hide-col - Hide current column
Vaccination Status Person D Refresh_max hide-col - Hide current column
Vaccination Status Person D Vaccination sort-asc [ sort ascending by current column; replace any existing sort criteria
Vaccination Status Person D resize-cols-max g_ resize all cols to max
open-file Person_E.csv o
rename-sheet Vaccinations Person E Rename current sheet
Vaccinations Person E Vaccination key-col ! toggle current column as a key column
Vaccinations Person E Date sort-desc ] sort descending by current column; replace any existing sort criteria
Vaccinations Person E Date aggregate-col max + Add aggregator to current column
Vaccinations Person E Date aggregate-col list + Add aggregator to current column
Vaccinations Person E RefreshTarget type-int # set type of current column to int
Vaccinations Person E RefreshTarget addcol-expr str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' = create new column from Python expression, with column names as variables
Vaccinations Person E str(date(Date)+datetime.timedelta(weeks=RefreshTarget)) if RefreshTarget else f'{"✔": <10}' rename-col Refresh ^ rename current column
Vaccinations Person E Refresh aggregate-col max + Add aggregator to current column
Vaccinations Person E resize-cols-max g_ resize all cols to max
Vaccinations Person E Vaccination freq-col Shift+F open Frequency Table grouped on current column, with aggregations of other columns
rename-sheet Vaccination Status Person E Rename current sheet
Vaccination Status Person E Vaccination addcol-expr f', '.join(map(str, Date_list)) = create new column from Python expression, with column names as variables
Vaccination Status Person E f', '.join(map(str, Date_list)) rename-col Vaccinations ^ edit name of current column
Vaccination Status Person E Vaccination addcol-expr f'{Refresh_max} (#{count}: {Date_max})' = create new column from Python expression, with column names as variables
Vaccination Status Person E f'{Refresh_max} (#{count}: {Date_max})' rename-col Refresh ^ edit name of current column
Vaccination Status Person E count hide-col - Hide current column
Vaccination Status Person E Date_max hide-col - Hide current column
Vaccination Status Person E Date_list hide-col - Hide current column
Vaccination Status Person E Refresh_max hide-col - Hide current column
Vaccination Status Person E Vaccination sort-asc [ sort ascending by current column; replace any existing sort criteria
Vaccination Status Person E resize-cols-max g_ resize all cols to max
sheets-stack Shift+S open Sheets Stack: join or jump between the active sheets on the current stack
sheets キVaccination Status Person A select-row s select current row
sheets キVaccination Status Person B select-row s select current row
sheets キVaccination Status Person C select-row s select current row
sheets キVaccination Status Person D select-row s select current row
sheets キVaccination Status Person E select-row s select current row
sheets join-selected full & merge selected sheets with visible columns from all, keeping rows according to jointype
rename-sheet Vaccination Status Overview Rename current sheet
sheets resize-cols-max g_ resize all cols to max
Vaccination Status Overview Vaccination Status Person A_Vaccinations hide-col - Hide current column
Vaccination Status Overview Vaccination Status Person B_Vaccinations hide-col - Hide current column
Vaccination Status Overview Vaccination Status Person C_Vaccinations hide-col - Hide current column
Vaccination Status Overview Vaccination Status Person D_Vaccinations hide-col - Hide current column
Vaccination Status Overview Vaccination Status Person E_Vaccinations hide-col - Hide current column
Vaccination Status Overview Vaccination Status Person A_Refresh rename-col Person A ^ edit name of current column
Vaccination Status Overview Vaccination Status Person B_Refresh rename-col Person B ^ edit name of current column
Vaccination Status Overview Vaccination Status Person C_Refresh rename-col Person C ^ edit name of current column
Vaccination Status Overview Vaccination Status Person D_Refresh rename-col Person D ^ edit name of current column
Vaccination Status Overview Vaccination Status Person E_Refresh rename-col Person E ^ edit name of current column
Vaccination Status Overview Vaccination sort-asc [ sort ascending by current column; replace any existing sort criteria
Vaccination Status Overview resize-cols-max g_ resize all cols to max
Vaccination Status Overview Person A slide-rightmost gShift+L slide current column all the way to the right of sheet
Vaccination Status Overview Person B slide-rightmost gShift+L slide current column all the way to the right of sheet
Vaccination Status Overview Person C slide-rightmost gShift+L slide current column all the way to the right of sheet
Vaccination Status Overview Person D slide-rightmost gShift+L slide current column all the way to the right of sheet
Vaccination Status Overview Person E slide-rightmost gShift+L slide current column all the way to the right of sheet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment