LTspice's polar: (db,deg) format uses ° (degree, 0xb0), a 1-byte character in ISO/IEC 8859-1. This makes it difficult to handle text data in multi-byte environments such as Japanese due to garbled characters.
So I wrote a shell script to convert the data to CSV or Tab delimited text so that it can be easily handled by Microsoft Excel or gnuplot. It can be used in environments where sed and bash are available.
When the script name is "polar2csv", it converts the LTspice polar: (db,deg) format to CSV and outputs it to the standard output. If the script name is something other than polar2csv (e.g. polar2tab), it will convert the data to Tab-delimited text and output it to the standard output.
polar2csv / polar2txt (shell script)
#!/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