Extracting timeseries tables from string into dictionary : <p>I have a text file that contains several time series data that looks like this:</p>

<pre><code>Elect Price 
(Jenkins 1989)

1960 6.64784
1961 6.95902
1962 6.8534
1963 6.95924
1964 6.77416
1965 6.96237
1966 6.94241
1967 6.50688
1968 5.72611
1969 5.45512
1970 5.2703
1971 5.75105
1972 5.26886
1973 5.06676
1975 6.14003
1976 5.44883
1977 6.49034
1978 7.17429
1979 7.87244
1980 9.20048
1981 7.35384
1982 6.44922
1983 5.44273
1984 4.3131
1985 5.27546
1986 4.99998
1987 5.78054
1988 5.65552

Hydro Electricity 
(Guyol 1969; Energy Information Administration 1995)

1958 5.74306e+009
1959 5.90702e+009
1960 6.40238e+009
1961 6.77396e+009
1962 7.12661e+009
1963 7.47073e+009
1964 7.72361e+009
1980 1.62e+010
1985 1.85e+010
1986 1.88e+010
1987 1.89e+010
1988 1.96e+010
1989 1.95e+010
1990 2.02e+010
1991 2.05e+010
1992 2.04e+010
1993 2.12e+010

Nuclear Electricity
(Guyol 1969; Energy Information Administration 1995)

1958 4.43664e+006
1959 1.34129e+007
1960 2.56183e+007
1961 4.09594e+007
1962 6.09336e+007
1963 1.09025e+008
1964 1.59522e+008
1980 6.40598e+009
1985 1.33e+010
1986 1.42e+010
1987 1.55e+010
1988 1.68e+010
1989 1.73e+010
1990 1.77e+010
1991 1.86e+010
1992 1.88e+010
1993 1.95e+010
</code></pre>

<p>I have it loaded up as a single string and I am wondering what the best way would be to convert it into a dictionary of the form:</p>

<pre><code>{('Elect Price', '(Jenkins 1989)'): [(1960, 6.64784), (1961, 6.95902), (1962, 6.8534), ...], ...}
</code></pre>

<p>My first instinct is to go line by line through the string and check to see if a few different regular expressions match and go from there, but I'd also have to include logic to handle what to do after a variable name is matched, then the citation, and the data, etc.</p>

<p>Is there a better way to do this? Possibly with some kind of template to extract the variable name, citation, and data as mentioned? I'm sure this is a fairly common task so I'm assuming there are more standard methods/tools for this.</p>
