I'm sorry for my English. I look for tool or script for combining text fields in this way: e.g.

field_1 (contains 3 to 6 signs)

field_2 (contains 6 to 10 signs)

[field_1] & x & [field_2]

where x = variable number of signs (e.g. "-" or "0") which will give me globally always 25 characters as a result of combining. I'm working in arcgis or qgis. It could be also tool in acces or excel.

  • 2
    '%s%s' %(!field_1!,!field_2!.zfill(25-len(!Field_1!)-len(!Field_2!)))
    – FelixIP
    Nov 2 '15 at 19:10
  • it is python ??? Nov 2 '15 at 19:16
  • 1
    It is python expression for field calculator in ArcGIS
    – FelixIP
    Nov 2 '15 at 19:18
  • !field_1!+!field_2!.zfill(25-len(!field_1!)) Nov 2 '15 at 20:32
  • now it seems working :) - thanks for python lesson :) Nov 2 '15 at 20:33

Calculate the total length of the two fields. Then subtract that number from 25 to get y Then create a string y characters long.

Create a table, with two columns. One column with the count of characters, One column with a character string y characters long (Field Y)

Then calculate a new field (field 5) as field1+field y+field2.

There are likely better ways to do it, but this should get it done.


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.