sheetImport

Source: sheetImport.js:17

Importing Joshua's workout history from his Google Sheets ("Workout Progress - Upper Body / Lower Body / Core", exported as CSV). Each sheet is a grid: the first row is session dates (newest first), each later row an exercise, and each cell what was done that day, as ;-separated groups of weight, reps:

300lbs, 10 one set of 10 at 300 lbs 60lbs, 2x5 2 sets of 5 50lbs, 6,10 a set of 6, then a set of 10 3x8 bodyweight: 3 sets of 8 02:00:00 / 2x 30 seconds / 5x0:30 timed holds (Sheets turns 2:00 into 02:00:00)

Anything else is read as far as it can be, and the cell's own text is kept in the workout's note so nothing is lost. This module only parses; scripts/import-sheets.js writes to the database.


Other

parseCsv

Parse CSV text (RFC 4180: quoted fields, "" for a quote, commas and line breaks inside quotes, CRLF, a BOM).

Parameters

  • text (string)

Returns

  • Array.<Array.<string>>

spellingFixes

Known misspellings in the sheets, fixed on import (the original text goes in the report).

cleanName

An exercise name as stored: trimmed, single-spaced, known typos fixed.

Parameters

  • name (string)

Returns

  • string

nameKey

The key two names are matched by: case and spacing don't matter ("Seated leg curl" is "Seated Leg Curl").

Parameters

  • name (string)

Returns

  • string

readDuration

A timed effort as written in the sheet, or null when the text isn't a time: 02:00:00 (Sheets' reading of 2:00) becomes 2:00, 00:20 becomes 0:20, 30 seconds stays.

Parameters

  • text (string)

Returns

  • string | null

readReps

Read a list of reps like 10, 2x5, 6,10, 2x6, 4 into set groups.

Parameters

  • text (string)

Returns

  • Array.<{sets: number, reps: number}> | null — null when any part isn't a rep count.

readGroup

One ;-separated group of a cell: a weight (optional) and its reps, or a timed hold.

Parameters

  • text (string)

Returns

  • Object — exact is false when part of the text couldn't be read (the cell's text then goes in the note).

readCell

A whole cell: its groups, in order.

Parameters

  • text (string)

Returns

  • Object

parseSheet

A sheet's CSV as workouts.

Parameters

  • text (string)
  • area (string) — The sheet's body area, e.g. 'upper'.

Returns

  • Object

equipmentRules

Equipment guessed from an exercise's name, checked in order; a name can match several.

guessEquipment

Equipment an exercise probably uses, from its name. A guess for Joshua to review; an empty list means bodyweight or unknown.

Parameters

  • name (string)

Returns

  • Array.<string>