AnsweredAssumed Answered

typeError about wrong type where type isn't relevant

Question asked by menno.nijhuis on Feb 14, 2012
Latest reply on Feb 14, 2012 by menno.nijhuis
My script below produces the following output and error:
DLB legger_kanaal.gdb L:\20_Productie\versie 0.3\DLB\data\legger_kanaal.gdb vStuw L:\20_Productie\versie 0.3\DLB\data\legger_kanaal.gdb\vStuw Traceback (most recent call last):   File "<string>", line 248, in run_nodebug   File "C:\Users\nijhm\Desktop\", line 41, in <module>     for kw in kunstwerklist: TypeError: object of type 'dict' has no len()

I've hashed out all but one of the dict items, this has made no difference, neither did shortening the 'kunstwerklist' to one item. Print statements were only added for clearance when debugging.
I've fiddled around with the script a little. Before I did that it produced the same error (at the line with fgdb = os.path.join(leggermap,rd,'data',db))but traced it also back to (os module) line 96 which does indeed include a len() method, whereas my script doesn't. Also, the input to the os.path.join is in no case a <type 'dict'>, apart from the fact that getting a len() from a dictionary shouldn't be a problem.
Also, when reproducing the script step by step in the Python interpreter window (without dictionary or for loops), no error occurs.

Most important finding thusfar (and reason of posting here and not on when hashing out the gp.TableToDBASE_conversion(), the script simply prints as it is instructed to do and does not produce an error!

Please reply if you have any ideas of why this might go wrong, or have any other idea of exporting a lot of gdb tables to dbf.

import os, arcgisscripting gp = arcgisscripting.create(9.3)  exportmap = r'L:\20_Productie\versie 0.3\Werk\kunstwerktabellen' leggermap = r'L:\20_Productie\versie 0.3'  dictType = { ##              "DIJG":["legger_openwater.gdb"], ##              "DNB":["legger_kanaal.gdb"], ##              "DNH":["legger_openwater.gdb","legger_kanaal.gdb"], ##              "DNN":["legger_openwater.gdb"], ##              "DON":["legger_kanaal.gdb","legger_rivier.gdb"],               "DLB":["legger_kanaal.gdb","legger_rivier.gdb"], ##              "DUT":["legger_kanaal.gdb"], ##              "DZH":["legger_rivier.gdb"], ##              "DZL":["legger_openwater.gdb","legger_kanaal.gdb"]               }  ##kunstwerklist = ['vStuw','vSchutsluis','vInUitwateringSluis','vWaterReguleringsWerk','vGemaal'] kunstwerklist = ['vStuw'] exportlist = []  for rd in dictType:     print rd     for db in dictType[rd]:         print db         fgdb = os.path.join(leggermap,rd,'data',db)         print fgdb         for kw in kunstwerklist: ## THIS IS LINE 41             print kw             geval = os.path.join(fgdb,kw)             print geval             gp.TableToDBASE_conversion(geval,exportmap)             exportlist.append(geval)  print exportlist del gp

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32.
Pyscripter (but also crashes in IDLE 2.6.5)
ArcGIS Desktop 10.0 SP3
Win7 x64