Created
September 25, 2018 22:34
-
-
Save jondoesntgit/6afbb1bf8d3ccbaa97d5a2fa2a2c9693 to your computer and use it in GitHub Desktop.
LTSpice to Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some regular expression for parsing LTSpice gain files | |
import re | |
regex = r"^([\.0-9e+-]+)\t\(([\.0-9e+-]+)dB,([-0-9\.e+-]+)°\)" | |
path = # Insert your path here | |
with open(path) as file: | |
matches = re.finditer(regex, file.read(), re.MULTILINE) | |
freq, gain, phase = zip(*[(float(m.group(1)), float(m.group(2)), float(m.group(3))) for m in matches]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment