convert string to other type in python
<p>Hi everyone I have a simple problem but I don't find the solution, I have a function that returns something like that</p>

<pre><code>[[4, 'adr', 0, 0, 1, '2016-04-05T13:00:01'], [115, 'adr', 0, 0, 1, '2016-04-05T14:00:01'], [226, 'adr', 0, 0, 1, '2016-04-05T15:00:01'], [337, 'adr', 0, 0, 1, '2016-04-05T16:00:01']]
</code></pre>

<p>when I check de type of this variable <code>type(data)</code>say that is a string <code>&lt;type 'str'&gt;</code>
I want to create a loop to get each element like this </p>

<p>item 1 <code>[4, 'adr', 0, 0, 1, '2016-04-05T13:00:01']</code></p>

<p>item 2 <code>[115, 'adr', 0, 0, 1, '2016-04-05T14:00:01']</code></p>

<p>I try to convert the string in a list, a tuple... but nothing work, any idea how to change the string to any type that I can do a loop and get the items</p>

<p>when I try to convert in a tuple or string I have this result</p>

<pre><code>('[', '[', '4', ',', ' ', "'", 'a', 'd', 'r', "'", ',', ' ', '0', ',', ' ', '0', ',', ' ', '1', ',', ' ', "'", '2', '0', '1', '6', '-', '0', '4', '-', '0', '5', 'T', '1', '3', ':', '0', '0', ':', '0', '1', "'", ']', ',', ' ', '[', '1', '1', '5', ',', ' ', "'", 'a', 'd', 'r', "'", ',', ' ', '0', ',', ' ', '0', ',', ' ', '1', ',', ' ', "'", '2', '0', '1', '6', '-', '0', '4', '-', '0', '5', 'T', '1', '4', ':', '0', '0', ':', '0', '1', "'", ']', ',', ' ', '[', '2', '2', '6', ',', ' ', "'", 'a', 'd', 'r', "'", ',', ' ', '0', ',', ' ', '0', ',', ' ', '1', ',', ' ', "'", '2', '0', '1', '6', '-', '0', '4', '-', '0', '5', 'T', '1', '5', ':', '0', '0', ':', '0', '1', "'", ']', ',', ' ', '[', '3', '3', '7', ',', ' ', "'", 'a', 'd', 'r', "'", ',', ' ', '0', ',', ' ', '0', ',', ' ', '1', ',', ' ', "'", '2', '0', '1', '6', '-', '0', '4', '-', '0', '5', 'T', '1', '6', ':', '0', '0', ':', '0', '1', "'", ']', ']')
</code></pre>

<p>Hi everyone I finally resolve the problem like this</p>

<pre><code>data = {}
data = {'names': []}
for item in project_name:
  data['names'].append(item)
  data.update({item: {}})
  jobs_running = []
  jobs_pending = []
  for row in all_rows:
    if (str(item) == row[1]):
      parsed_t = dp.parse(str(row[5]))
      t_in_seconds = parsed_t.strftime('%s')

      jobs_running.append([ (t_in_seconds), (row[3]) ])
      jobs_pending.append([ (t_in_seconds), (row[4]) ])
      data[item].update({'jobs_running': jobs_running})
      data[item].update({'jobs_pending': jobs_pending})
</code></pre>

<p>So my data structure is like this <a href="http://i.stack.imgur.com/aPANZ.png" rel="nofollow">see image</a></p>

python python-2.7