from linecache import getline
import csv

line = getline("00v.s2p", 406)
print(line)

files = [
"00v.s2p",
"02v.s2p",
"04v.s2p",
"06v.s2p",
"08v.s2p",
"10v.s2p",
"12v.s2p",
"14v.s2p",
"16v.s2p",
"18v.s2p",
"20v.s2p",
"22v.s2p",
"24v.s2p",
"26v.s2p",
"27v.s2p",
"27.5v.s2p",
"28v.s2p",
"28.5v.s2p",
"29v.s2p",
"29.5v.s2p",
"30v.s2p"]

with open("modulator.csv","w") as cs:
    writer = csv.writer(cs, delimiter=',')
    for f in files:
        V = float(f.split('v')[0])
        line = getline(f,406).split()
        s21 = float(line[3])
        ph = float(line[4])
        writer.writerow([V,s21,ph])


