diff options
| author | Warrick Lo <warrick.s.z.lo@gmail.com> | 2026-02-16 03:08:14 -0800 |
|---|---|---|
| committer | Warrick Lo <warrick.s.z.lo@gmail.com> | 2026-02-16 03:08:14 -0800 |
| commit | 0aeeca161c38124b99c0c75fd16351642705ce6b (patch) | |
| tree | 441721fa768f9b75fe2559d0a4e203c514c76904 /prep.sh | |
Signed-off-by: Warrick Lo <warrick.s.z.lo@gmail.com>
Diffstat (limited to 'prep.sh')
| -rwxr-xr-x | prep.sh | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -0,0 +1,26 @@ +#!/bin/sh + +# Prepare all waveform data for MATLAB processing. +# +# This script will: +# 1. sanitise the header before running MATLAB's readtable(); +# 2. convert line endings from DOS to UNIX; and +# 3. rename files to have *.tsv file extensions. +# +# This script assumes all waveform data is tab-delimited and +# stored in *.txt files. +# +# Usage: ./prep.sh + +files=$(ls -- *.txt) + +for i in $files; do + printf "Preparing %s\n" "$i" + + # Replace the header and convert DOS line endings (CRLF) + # to UNIX line endings (LF). + sed -i -e "1c time\tv1\tv2\tv3\ti1\ti2\ti3" -e "s/\x1D$//" "$i" + + # Rename files to have TSV extensions. + mv "$i" "${i%.*}.tsv" +done |