0

I have dataset that has columns that need to be sorted based on multiple columns.

The first column contains a name and the second a number, the names are not unique. What I want is a NewID from 1 to 10 per name based on the descending value of the number. Like this: example

Any ideas how this can be done? Preferably in ArcMap.

asked May 12, 2017 at 9:53
4
  • Do you need a python script or step by step algorithm as an answer? Commented May 12, 2017 at 10:20
  • Python script that can be used in field calculator would be nice. Commented May 12, 2017 at 10:24
  • 1
    ArcMap and FME require different solutions, which makes this question too broad. A Python solution requires you to provide the code you've developed to date. Please Edit the question. Commented May 12, 2017 at 10:35
  • I removed FME, I currently do not have a python script. Commented May 12, 2017 at 11:23

2 Answers 2

0

I know you removed FME but for the record, a Sorter, sorting by the NameID and then secondly the number, followed by a Counter with the Counter ID set to the value of the NameID attribute will do exactly what you want.

answered May 12, 2017 at 14:07
0
0

This is will not answer your question but it might help you to solve your problem. Here is how to sort lists in python:

import pprint
table = [
 [1,'H',-1],
 [2,'D',2],
 [3,'D',8],
 [4,'D',1],
 [5,'H',68],
 [6,'H',97],
 [7,'H',88],
]
print 'Before sorting:'
print '[OBJECTID, NameID, Number]'
pprint.pprint(table)
print 
print 'After sorting:'
print '[OBJECTID, NameID, Number]'
pprint.pprint(
 sorted(table, key=lambda x: (x[1], x[2]))
 )

Excetuting this script gives:

Before sorting:
[OBJECTID, NameID, Number]
[[1, 'H', -1],
 [2, 'D', 2],
 [3, 'D', 8],
 [4, 'D', 1],
 [5, 'H', 68],
 [6, 'H', 97],
 [7, 'H', 88]]
After sorting:
[OBJECTID, NameID, Number]
[[4, 'D', 1],
 [2, 'D', 2],
 [3, 'D', 8],
 [1, 'H', -1],
 [5, 'H', 68],
 [7, 'H', 88],
 [6, 'H', 97]]
answered May 12, 2017 at 12:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.