Luis Henrique Rodovalho
05/28/2022, 8:36 AM* resistor tb
r0 a 0 1k
va a 0 0
.control
dc va -1 1 0.2
wrdata res.txt v(a) i(va)
shell sed 's/^/ /; s/ /,/g; s/ /,/g; s/^,//g' res.txt > res.csv
.endc
.end
This outputs this text file, res.txt
-1.00000000e+00 -1.00000000e+00 -1.00000000e+00 1.00000000e-03
-8.00000000e-01 -8.00000000e-01 -8.00000000e-01 8.00000000e-04
-6.00000000e-01 -6.00000000e-01 -6.00000000e-01 6.00000000e-04
-4.00000000e-01 -4.00000000e-01 -4.00000000e-01 4.00000000e-04
-2.00000000e-01 -2.00000000e-01 -2.00000000e-01 2.00000000e-04
-5.55111512e-17 -5.55111512e-17 -5.55111512e-17 5.55111512e-20
2.00000000e-01 2.00000000e-01 2.00000000e-01 -2.00000000e-04
4.00000000e-01 4.00000000e-01 4.00000000e-01 -4.00000000e-04
6.00000000e-01 6.00000000e-01 6.00000000e-01 -6.00000000e-04
8.00000000e-01 8.00000000e-01 8.00000000e-01 -8.00000000e-04
1.00000000e+00 1.00000000e+00 1.00000000e+00 -1.00000000e-03
It well aligned, but I really wanted this:
-1.00000000e+00,-1.00000000e+00,-1.00000000e+00,1.00000000e-03,
-8.00000000e-01,-8.00000000e-01,-8.00000000e-01,8.00000000e-04,
-6.00000000e-01,-6.00000000e-01,-6.00000000e-01,6.00000000e-04,
-4.00000000e-01,-4.00000000e-01,-4.00000000e-01,4.00000000e-04,
-2.00000000e-01,-2.00000000e-01,-2.00000000e-01,2.00000000e-04,
-5.55111512e-17,-5.55111512e-17,-5.55111512e-17,5.55111512e-20,
2.00000000e-01,2.00000000e-01,2.00000000e-01,-2.00000000e-04,
4.00000000e-01,4.00000000e-01,4.00000000e-01,-4.00000000e-04,
6.00000000e-01,6.00000000e-01,6.00000000e-01,-6.00000000e-04,
8.00000000e-01,8.00000000e-01,8.00000000e-01,-8.00000000e-04,
1.00000000e+00,1.00000000e+00,1.00000000e+00,-1.00000000e-03,
This can be done by using the bash shell command shell sed 's/^/ /; s/ /,/g; s/ /,/g; s/^,//g' res.txt > res.csv
. I've tried to do that using the ngspice shell command but it gives me an error: `sed: -e expression #1, char 4: unterminated s' command
. Can someone explain me this? @Jorge MarinChristoph Weiser
05/28/2022, 8:54 AMimport pandas as pd
df = pd.read_csv("res.txt", delim_whitespace=True)
Luis Henrique Rodovalho
05/28/2022, 8:57 AMyrrapt
05/28/2022, 8:57 AMChristoph Weiser
05/28/2022, 9:00 AM