<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Convert dbf to numpy array in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/convert-dbf-to-numpy-array/m-p/449425#M35189</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks!&amp;nbsp; I'm still pretty new to Python, so never would have found that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is the code that I came up with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from numpy import *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.SearchCursor("Z://Code//EX2_near.dbf","","","","")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;currentIN_FID = "" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;currentNear_FID = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;currentNear_Dist = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;newdata = []&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Iterate through the rows in the cursor &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in rows: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowN = [row.IN_FID, row.NEAR_FID, row.NEAR_DIST]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newdata.append (rowN)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print newdata&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;datatwo = array([newdata])&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Dec 2011 14:08:02 GMT</pubDate>
    <dc:creator>AlexanderKeyel</dc:creator>
    <dc:date>2011-12-16T14:08:02Z</dc:date>
    <item>
      <title>Convert dbf to numpy array</title>
      <link>https://community.esri.com/t5/python-questions/convert-dbf-to-numpy-array/m-p/449423#M35187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to use Python to convert a data table in .dbf format generated by ArcGIS 10 to a Numpy array.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a simple way to do this?&amp;nbsp; Forgive me if this is a naive question, but I was unable to find anything on the help pages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 21:02:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-dbf-to-numpy-array/m-p/449423#M35187</guid>
      <dc:creator>AlexanderKeyel</dc:creator>
      <dc:date>2011-12-15T21:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Convert dbf to numpy array</title>
      <link>https://community.esri.com/t5/python-questions/convert-dbf-to-numpy-array/m-p/449424#M35188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't have an example, but basically you would have to use a search cursor to loop through the fields and records.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001q000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001q000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Dec 2011 22:04:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-dbf-to-numpy-array/m-p/449424#M35188</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2011-12-15T22:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert dbf to numpy array</title>
      <link>https://community.esri.com/t5/python-questions/convert-dbf-to-numpy-array/m-p/449425#M35189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks!&amp;nbsp; I'm still pretty new to Python, so never would have found that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is the code that I came up with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from numpy import *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.SearchCursor("Z://Code//EX2_near.dbf","","","","")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;currentIN_FID = "" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;currentNear_FID = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;currentNear_Dist = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;newdata = []&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Iterate through the rows in the cursor &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for row in rows: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowN = [row.IN_FID, row.NEAR_FID, row.NEAR_DIST]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newdata.append (rowN)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print newdata&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;datatwo = array([newdata])&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Dec 2011 14:08:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-dbf-to-numpy-array/m-p/449425#M35189</guid>
      <dc:creator>AlexanderKeyel</dc:creator>
      <dc:date>2011-12-16T14:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Convert dbf to numpy array</title>
      <link>https://community.esri.com/t5/python-questions/convert-dbf-to-numpy-array/m-p/449426#M35190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yep -&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, if you wanted to "variabalize" the field names (use the field names as varaibles) it would look like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;from numpy import *
import arcpy
rows = arcpy.SearchCursor("Z://Code//EX2_near.dbf","","","","")
currentIN_FID = "IN_FID" 
currentNear_FID = "NEAR_FID"
currentNear_Dist = "NEAR_DIST"
newdata = []
# Iterate through the rows in the cursor 
for row in rows: 
&amp;nbsp;&amp;nbsp; rowN = [row.getValue(currentIN_FID), row.getValue(currentNear_FID), row.getValue(currentNear_Dist)]
&amp;nbsp;&amp;nbsp; newdata.append (rowN)
del row, rows #be sure to delete the cursor objects, otherwise a lock on the table will persist!!!
print newdata
datatwo = array([newdata]) &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-dbf-to-numpy-array/m-p/449426#M35190</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T20:03:44Z</dc:date>
    </item>
  </channel>
</rss>

