<div dir="ltr">You can try subprocess.check_output with -json option.<div>It will save a structure with your desidered information.<br><div><br></div><div><a href="https://docs.python.org/2/library/subprocess.html" target="_top" rel="nofollow" link="external">https://docs.python.org/2/library/subprocess.html</a></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-03-29 16:18 GMT+02:00 Even Rouault-2 [via OSGeo.org] <span dir="ltr"><<a href="/user/SendEmail.jtp?type=node&node=5314824&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>></span>:<br><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">On mercredi 29 mars 2017 06:51:11 CEST Johan de Braak wrote:</p>
</span><span class=""><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> Hi all,</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> Using gdal.Info in Python, I would like to have my result as a dictionary</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> instead of a string. I found that in gdal.InfoOptions I am able to specify</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> 'format'. By default, this is set to 'text', however changing this to 'dict'</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> (or anything really) does still result in a string.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> Is there a way to get the gdal.Info result as something else than a string?</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
</span><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Yes: format = 'json'</p><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> Johan</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> --</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> View this message in context:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> <a href="http://osgeo-org.1560.x6.nabble.com/gdal-Info-Options-Python-tp5314816.html" target="_blank" rel="nofollow" link="external">http://osgeo-org.1560.x6.<wbr>nabble.com/gdal-Info-Options-<wbr>Python-tp5314816.html</a></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> Sent from the GDAL - Dev mailing list archive at Nabble.com.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> ______________________________<wbr>_________________</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> gdal-dev mailing list</p>
</span><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> <a href="http:///user/SendEmail.jtp?type=node&node=5314820&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a></p><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> <a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank" rel="nofollow" link="external">https://lists.osgeo.org/<wbr>mailman/listinfo/gdal-dev</a></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">-- </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Spatialys - Geospatial professional services</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><a href="http://www.spatialys.com" target="_blank" rel="nofollow" link="external">http://www.spatialys.com</a></p><br></span>______________________________<wbr>_________________
<br>gdal-dev mailing list
<br><a href="http:///user/SendEmail.jtp?type=node&node=5314820&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="nofollow" link="external" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/gdal-dev</a>
<br>
<br>
<hr noshade size="1" color="#cccccc">
<div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
<div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
<a href="http://osgeo-org.1560.x6.nabble.com/gdal-Info-Options-Python-tp5314816p5314820.html" target="_blank" rel="nofollow" link="external">http://osgeo-org.1560.x6.<wbr>nabble.com/gdal-Info-Options-<wbr>Python-tp5314816p5314820.html</a>
</div>
<div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
To start a new topic under GDAL - Dev, email <a href="/user/SendEmail.jtp?type=node&node=5314824&i=1" target="_top" rel="nofollow" link="external">[hidden email]</a> <br>
To unsubscribe from GDAL - Dev, <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>
<a href="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
</div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><pre cols="72" style="white-space:pre-wrap;color:rgb(136,136,136)">Lorenzo Bernardi
NAIS Srl (<a href="http://www.nais-solutions.it/" style="color:rgb(17,85,204)" target="_blank" rel="nofollow" link="external">www.nais-solutions.it</a>)
Via Andrea Noale 345/A
00155 Rome – Italy
<br></pre></div></div>
</div>
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/gdal-Info-Options-Python-tp5314816p5314824.html">Re: gdal Info Options Python</a><br/>
Sent from the <a href="http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html">GDAL - Dev mailing list archive</a> at Nabble.com.<br/>