Friday, September 25, 2009

Table to HTML table

Sometimes it's necessary to generate an html table for returned results. This tool basically takes any format that can support a search cursor, and generates an HTML file on your local disk. I was using this script in conjunction with some reporting tools to analyze AGS server logs.

Enjoy, and I hope it sparks some great GP ideas.



# ---------------------------------------------------------------------------
# TableToHtml.py
# ---------------------------------------------------------------------------

import sys, string, os, arcgisscripting
gp = arcgisscripting.create(9.3)

tablePath = gp.GetParameterAsText(0)
filePath = gp.GetParameterAsText(1)

outfile = open(filePath, "w")
fields = gp.ListFields(tablePath)

fieldNames = []
for field in fields:
if (field.type <> "Geometry" and field.type <> "BLOB"):
fieldNames.append(field.name)

outfile.write(" <table border=""1"">\n")

outfile.write(" <tbody><tr>\n")
for fieldName in fieldNames:
outfile.write(" <th>" + fieldName + "</th>\n")

outfile.write("</tr>\n")

cur = gp.SearchCursor(tablePath)
row = cur.Next()
while row:
outfile.write(" <tr>\n")
for fieldName in fieldNames:
outfile.write(" <td>" + str(row.getValue(fieldName)) + "</td>\n")

outfile.write("</tr>\n")

row = cur.Next()

del cur

outfile.write("</tbody></table>\n")

outfile.flush()
outfile.close()

Tuesday, September 22, 2009

ArcPad Tips and Thoughts

If anyone is developing for ArcPad 8.0, make sure you get service pack 1. This will correct a whole host of issues with the AXF files. Also, if you wish to connect to an AXF, here is an example:

dim objRSPS, pDS
Set objRSPS = Application.CreateAppObject("RecordSet")
Set pDS = Application.CreateAppObject("DataSource")
pDS.Open(pDSDataSource)
set objRSPS = pDS.OpenLayer("")
If objRSPS.RecordCount > 0 Then
objRSPS.MoveFirst
End If
...do other stuff...


So basically what is happening here, the objRSPS is creating a recordset object, then pDS is a data source object. pDS opens the data source via path name. objRSPS obtains the data set's records by referencing what layer you want from the axf database (axf is a compact sql server).

Note: the axf is picky, and it will tell you. If any domain values are invalid, it will catch it. So keep your databases clean if you are going to use this stuff.

Note 2: the shapefile is going away in arcpad, so get use to the AXF way of doing things.

Enjoy

Tuesday, September 15, 2009

Deprecation Plan for ArcGIS 9.3.1 and ArcGIS 9.4

The deprecation plans for ArcGIS 9.3.1 and ArcGIS 9.4 can be found here. It shows that VBA and VB6 are finally going away and there are OS support changes planned also. It's time for people to move on to new technologies, so start getting ready to transition now.