1

I am using Arcpy to load a table from Excel. One of the fields has a lot of text (up to 2000 characters) and when using arcpy.MakeTableView_management the field is given the type 'BLOB'. Is there any way to either prevent this from happening, i.e. making sure the field type is 'Text', or is there a way of reading the text in python so the data can be used?

I have read BLOB TYPE in Arcmap but it does not answer the question. I am specifically trying to read the data in Python, while the previous question referred to reading it in ArcMap.

11
  • 1
    How is this not a duplicste of the referenced question?
    – Vince
    Oct 13 '16 at 11:08
  • I am specifically trying to read the data in Python, while the previous question referred to reading it in ArcMap Oct 13 '16 at 11:11
  • 2
    If it were an option, it would have been documented; therefore you need to write some code. What have you written so far?
    – Vince
    Oct 13 '16 at 11:19
  • I have been able to extract individual characters using memoryview(): rows = arcpy.da.SearchCursor("Table","Comments") for row in rows: memview = memoryview(row[0]) print memview[2] Oct 13 '16 at 11:26
  • 2
    Please edit your question for any requested clarifications.
    – PolyGeo
    Oct 13 '16 at 11:28
1

Reading Blobs:

from arcpy import da
import os
with da.SearchCursor(r"c:\temp\demo.gdb\table",['blobFieldname','fileName']) as cursor:
   for row in cursor:
      binaryRep = row[0]
      fileName = row[1]
      # save to disk
      open(r"c:\saveFolder" + os.sep + fileName, 'wb').write(binaryRep.tobytes())
      del row
      del binaryRep
      del fileName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.