3/26/2023 0 Comments Lf in notepad++ python![]() It may be easier to weed them in the table or in the text dump (which could then be re-imported to a table). That is the tool set you want for weeding out pesky newlines ('\n'). There is an 're' module in python that handles regular expressions. ![]() Try dumping the table to a text file, if you think there is stuff going on in there you cannot see. Row = row.replace(chr(10), eolchar).replace(chr(13), eolchar) With arcpy.da.UpdateCursor(tbl, ) as rows: and the "with" construct helps you out by closing the cursor even if the code fails - avoiding the possibility of a nasty hanging file lock!ĭef strip_newlines(tbl, field, eolchar=""): I'm also using arcpy.da.UpdateCursor because it is very fast compared to the 10.0 flavor. ![]() as the usual use of "\n" breaks the geoprocessing messaging string representation in the code. Note I'm using chr(10) and chr(13) for "\n" and "\r" so this function can also be used inside the Calculate Value tool in modelbuilder. You could paste this function into the ArcMap python window and use it there. Here's a function implementation of your approach, not using hex codes. ![]() This method seems a little dangerous as I can envision where the string "0a" could occur in your hex string by accident, for example the two byte hex "b0 ac" represented this way would be an invalid match. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |