<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 4, 2013 at 8:47 PM, Robert Winkler <span dir="ltr"><<a href="mailto:robert.winkler@bioprocess.org" target="_blank">robert.winkler@bioprocess.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div>
<p>Thanks to the OSA library, which works for SOAP requests with
Python 3.x, I can now use SOAP services at <a href="http://www.chemspider.com" rel="nofollow" target="_blank">http://www.chemspider.com</a>.</p>
<p>The result is a list of accession numbers (which correspond to
chemical compounds) and I get them in the following format:</p>
<pre><code><span>(</span><span>ArrayOfInt</span><span>){</span><span>
int</span><span>[]</span><span> </span><span>=</span><span> </span><span>[</span><span>
</span><span>5744</span><span>,</span><span>
</span><span>69182</span><span>,</span><span>
</span><span>292</span><span>,</span><span>
</span><span>68027</span><span>,</span><span>
</span><span>3404131</span><span>,</span><span>
</span><span>82616</span><span>,</span><span>
</span><span>18280</span><span>,</span><span>
</span><span>11200</span><span>,</span><span>
</span><span>704646</span><span>,</span><span>
</span><span>543430</span><span>
</span><span>...</span><span>
</span><span>]</span><span>
</span><span>}</span></code></pre>
<p>How could I transform this to a simple python list?</p>
<p><code>[5744, 69182, 292,68027, 3404131, 82616, 18280, 11200,
704646, 543430 ...]</code></p>
<p>Conversion to a numpy array (and subsequent <code>list()</code>,
or similar) does not solve the problem, since the structure is
maintained; the numpy.shape returns <code>()</code>.</p>
<p>Suggestions?</p>
</div>
</div>
<br></blockquote><div>Hi Robert,<br><br></div><div>You have not provided enough information. But going by the little we have here, you could turn the returned result into a string. Then parse the string with a regex. I have included a sample here. There are more elegant ways to do this but here's a quick and dirty solution to give you a heads up.<br>
<br><br>import sys<br>import re<br><br>retVal= '''(ArrayOfInt){ <br> int[] = [<br> 5744,<br> 69182,<br> 292,<br> 68027,<br> 3404131,<br>
82616,<br> 18280,<br> 11200,<br> 704646,<br> 543430,<br> ]<br> }'''<br><br>myList = re.findall(r'\d+', retVal)<br>
aList = list(myList)<br>print('[' + ', '.join(aList) + ']')<br><br><br></div><div>That should give you the desired list. Unless of course I'm missing the point.<br><br></div><div>Good luck,<br>
</div><div>Evans <br></div></div><br></div></div>