Skip to content

Instantly share code, notes, and snippets.

@ujaehrig
Last active July 27, 2021 07:38
Show Gist options
  • Save ujaehrig/5a0ba51985903d5b66e4796cd59aa395 to your computer and use it in GitHub Desktop.
Save ujaehrig/5a0ba51985903d5b66e4796cd59aa395 to your computer and use it in GitHub Desktop.
Script to prepare an Fritz!Box Anrufliste.csv to a format suitable for DB import
#!/usr/bin/env bash
# Remove first line (having the separator indicator)
# Change date from "dd.MM.yy hh:mm" to "yyyy-MM-dd hh:mm:ss" (with second always 00)
# Change duration from "hh:mm" to "hh:mm:ss" (with seconds always 00)
cat |
tail -n +2 |
sed -e 's/;\(..\)\.\(..\)\.\(..\) \(..:..\);/;20\3-\2-\1 \4:00;/g' |
sed -e 's/:\([0-9]\{2\}\)$/:\1:00/g'
#!/usr/bin/env bash
# Remove separator indicator
# Change date from "dd.MM.yy hh:mm" to "yyyy-MM-dd hh:mm"
# Change separator ; to ,
grep -v '^sep=;$' |
sed -e 's/;\(..\)\.\(..\)\.\(..\) \(..:..\);/;20\3-\2-\1 \4;/g' |
xsv fmt -d';'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment