#!/bin/sh
#
# polar2csv - Polar: (db,deg) format of the LTspice XVII to CSV conversion.
#
# Usage
# polar2csv input_file
#
# Example
# polar2csv input_file.txt > output_file.csv
#
# You must set LC_ALL=C to remove the single byte degree charactor (0xb0)
# used in the export text format of Polar: (dB,deg) of the AC simulation
# results of the LTspice XVII.
# In bash, $'string' causes "ANSI-C expansion". And that is what most of
# us expect when we use things like \t, \r, \n, etc.
# c.f. www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
#
export LC_ALL=C
if [ $# -ne 1 ]; then
echo "${0##*/} - Polar: (db,deg) format of the LTspice XVII to CSV conversion."
echo "Usage : ${0##*/} input_file"
exit;
fi
if [ "${0##*/}" = "polar2csv" ]; then
sed < $1 -e 's/^Freq/#Freq/' -e 's/[(,)]//g' -e 's/\xb0//g' -e $'s/\t/, /g' -e $'s/dB/, /g'
else
sed < $1 -e 's/^Freq/#Freq/' -e 's/[(,)]//g' -e 's/\xb0//g' -e $'s/dB/\t/g'
fi
#EOF
|