I have the following question about formatting a string which I use to create output file names.

I loop a SearchCursor to create .png file. I extract two columns form the cursor e.g. "GMS_ID" and "ID". (codepart - with arcpy.da.SearchCursor("dbk_object_test_SpatialJoin2",['GMS_ID','ID','SHAPE@']) as cur:)

Then I concatenate the two columns like:

vakkrt_name = str(row[0]) + "_" + str(row[1])

Almost at the end I use:

outpng = r"D:\\arcpy\\output\\DBK_" + format(vakkrt_name) + ".png"

to create the file reference and after that I use:

  arcpy.mapping.ExportToPNG(mxd, outpng,df,

to really create the file on disk.

The result is something like:


Can you help me by disabling the decimal point probably by using the Format method.

1 Answer 1


The format of your 2 fields is probably double. Turn them to integer first (with or without the string.format() method, but the latter is more elegant):

vakkrt_name = str(int(row[0])) + "_" + str(int(row[1]))


vakkrt_name = "{}_{}".format(int(row[0]), int(row[1]))
  • Thank you, GISGe. This method works fine for me. Problem solved!
    – user32324
    Commented Jun 1, 2015 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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