Skip to content

Instantly share code, notes, and snippets.

@nickjones
Created January 9, 2021 15:11
Show Gist options
  • Save nickjones/d3fe42b8ce4aca11fb95e4bd928f67b1 to your computer and use it in GitHub Desktop.
Save nickjones/d3fe42b8ce4aca11fb95e4bd928f67b1 to your computer and use it in GitHub Desktop.
Convert exported CSV from www.brewstat.us into a format suitable to import into BeerSmith3 using the normal "Import CSV" feature, not the Tilt one.
#!/usr/bin/env python3
import argparse
import csv
import time
argparser = argparse.ArgumentParser()
argparser.add_argument('--input', help='Input CSV from BrewStatus')
argparser.add_argument('--output', help='Output CSV filename to write')
args = argparser.parse_args()
first_row = True
with open(args.input, 'r') as infile:
in_csv = csv.reader(infile)
with open(args.output, 'w') as outfile:
out_csv = csv.writer(outfile, quoting=csv.QUOTE_ALL)
for row in in_csv:
if first_row:
out_csv.writerow(['Date','Temperature', 'Gravity','Day'])
first_row = False
continue
# Convert
# 2021-01-04T15:38:52.7950000
# to normal Tilt output
# "31 Mar 2019 02:02:34 PM"
t = time.strptime(row[0].split('.')[0], '%Y-%m-%dT%H:%M:%S')
fixed_time = time.strftime('%d %b %Y %I:%m:%S %p', t)
sg = row[4]
temp = row[5]
out_csv.writerow([fixed_time, temp, sg, '-'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment