Export Attatchments From Table. AttributeError: 'NoneType' object has no attribute 'tobytes'

1266
4
Jump to solution
11-01-2022 06:33 AM
Labels (2)
drewcole232
New Contributor III

Any ideas on why this might erroring out? I have tried it on another database and it worked. I made some modifications to the original script, but the same error remains. 

Update: It actually does copy 36 PDFs to a folder successfully before the error. Not sure why yet. I'm would expect 400+ attachments, I will keep digging. 

drewcole232_0-1667309258105.png

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Seems like you have empty attachments. Are there entries with DATA_SIZE = 0 ?

Try to include a where clause in the cursor:

with da.SearchCursor(inTable, ["DATA", "ATT_NAME"], "DATA IS NOT NULL") as cursor:
    #...

Have a great day!
Johannes

View solution in original post

4 Replies
JohannesLindner
MVP Frequent Contributor

Seems like you have empty attachments. Are there entries with DATA_SIZE = 0 ?

Try to include a where clause in the cursor:

with da.SearchCursor(inTable, ["DATA", "ATT_NAME"], "DATA IS NOT NULL") as cursor:
    #...

Have a great day!
Johannes
drewcole232
New Contributor III

Thanks for the tip! I just checked and there doesn't appear to be any records with DATA_SIZE = 0 

0 Kudos
drewcole232
New Contributor III

I decided to try this even though I couldn't find any entries with DATA_SIZE = 0 and it worked. Maybe there were some corrupt records or something, I'm not sure yet, but thank you! 

0 Kudos
drewcole232
New Contributor III

Update: It actually does copy 36 PDFs to a folder successfully. Not sure why yet. I'm would expect 400+ attachments, I will keep digging. 

 

0 Kudos