I have a set of strings that I extracted and stored into an array. Some of these contain variables that I want to extract, the problem is these are strings at the moment. So for example, one string would look like
s1 = 'DataFile=scan1.dat'
Others would look like
s2 = 'NumberOfChannels=32'
What I want to do is take s1 and s2 and extract from them info and store them as such:
DataFile='scan1.dat'
NumberOfChannels=32
The strings all look similar to the ones above. It's either a variable that contains a string itself, or a variable containing an integer. Here's my (failed) attempt at the integer case:
# ll is a string element of the big array
if ll.startswith('NumberOfChannels'):
print "found nChans"
idx = ll.index('=')
vars()[ll[:idx-1]] = int(ll[idx+1:])
Any suggestions/external modules that could help me out would be greatly appreciated