Tuesday, September 8 · 9:00 am – 12:00 pm PT · Google Sheets
File ▸ Make a copy - this is now your sheet, in your Drivetidy-data-yournameHelpers: anyone without the link or a Google account, jump in via chat now.
On Zoom: drop answers in the chat. I'll read a few out.
Today we practise spotting and fixing where these have been broken, on real messy data.
2016_clean, not Copy of Sheet12016_messy tab ▸ Duplicate2016_cleanA rectangular table processes the same way on every row:
Some layouts are built to be read. A table is built to be processed. You can always build a nice view from a table; you cannot reliably process a pretty layout.
| session | date | registered | attended |
|---|---|---|---|
| RDM intro | 2016-03-04 | 18 | 12 |
| Open access | 2016-03-11 | 22 | 19 |
| Data mgmt | 2016-04-01 | 15 | 11 |
| Metadata | 2016-04-08 | 20 | 17 |
| Licensing | 2016-04-15 | 14 | 9 |
Look at what's left in 2016_messy. 60 seconds.
Drop one thing in the chat that a script could not read as data.
On Zoom: everyone types at once. No wrong answers; we're building the list together.
GQ & DF in one cell is two people45|0|0 in one cell is three countsVarious people recorded training attendance across 2016 and 2017, each their own way. You need to evaluate the programme and start doing statistics.
Working in your copies, make the 2016_messy and 2017_messy data something a computer can read, and put them together in one table.
2016_cleancheckpoint_clean / checkpoint_combinedOn Zoom: own copies. Green check = done, red x = stuck. Helpers watch the chat and DM you.
cancelled columnNotes tab) belongs in a separate file0 for missing. Never -999.-999 and 0-for-missing are sentinel values / magic numbers. Missing ≠ not-applicable ≠ zero ≠ unknown is null semanticsThese three cells all display 2016-03-04. What might differ underneath? What could be ambiguous?
File ▸ Settings ▸ Locale sets the default date format and how Sheets reads ambiguous date text (03/04/2016 as Mar 4 or Apr 3)ISDATE() - ISDATE("July 20 1969") is TRUE=ISNUMBER() / =ISTEXT()year/month/day, or a real date shown yyyy-mm-ddyyyy-mm-dd is the ISO 8601 standardIn dates (2015 data), add three columns:
=MONTH(date), =DAY(date), =YEAR(date). Format them as number.
Which two rows show the wrong year?
Download the dates tab as CSV. Open it in a plain-text editor - what happened to the dates? Re-open it in Sheets - now what?
On Zoom: own copies. Put the wrong-year row numbers in the chat; then say in the chat what the CSV did to the dates.
num_registered: whole number, 1 to 100.In dates: Data ▸ Sort range ▸ Advanced, tick Data has header row. Sort len_hours largest to smallest.
Notice anything strange? Try other columns.
Select num_attended. Format ▸ Conditional formatting ▸ Colour scale. Any strange values stand out?
On Zoom: own copies, ~6 minutes. Put what you find in the chat.
A CSV KEEPS
A CSV DROPS
File ▸ Download ▸ CSV = current sheet only. Five tabs, five files.GQ, DF is written "GQ, DF" so the comma isn't a new column; the real fix is one value per cellNotes tab in the workbook shows the wrong way: metadata inside the dataAI does not fix messy data. It gives a fluent, plausible answer even when its assumptions are wrong. Fluent is not correct.
yyyy-mm-dd → ISO 8601-999 is a sentinel valueYou don't need these today. You'll meet them again in R, in a database, in a data-management plan - now they won't be new.