I am trying to extract the time and signal change from a .vcd
file (Value change dump) in Python for analysis.
What I got:
# 100 (this is the timestamp)
['0', '#', '%']
['1', '@', '!']
What I hope to get:
# 100
['0', '#%']
['1', '@!']
This is my code:
import re
fname = input("Enter filename: ")
vcd = open(fname)
for line in vcd:
line = line.rstrip()
if re.findall('^#', line):
time = line
print(time)
elif re.findall('^0', line) or re.findall('^1', line):
sigVar = list(line)
for i in sigVar[1:]:
''.join(sigVar)
print(sigVar)
I couldn't join the elements in sigVar together. Any idea?
You can try like this :
>>> l = ['1','2','3']
>>> l[1:] = [''.join(l[1:])]
>>> l
['1', '23']