Created
February 18, 2016 23:27
-
-
Save max-te/59703b7ff5ccd52af874 to your computer and use it in GitHub Desktop.
Alphabetic Inventory Sorting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script needs a csv NEI Item Panel Dump. | |
# To get one make sure your search field is empty and go to | |
# the NEI Options > Tools > Item Panel. Make sure the left button is on CSV and click dump. | |
# Drop this script in the same directory as the generated itempanel.csv and run it. | |
# (Tested with Python 3.4) | |
# Move the InvTweaksTree.txt to your config directory. | |
import csv | |
def normalize(name): | |
return ''.join(char for char in name if char in 'abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') | |
with open('itempanel.csv') as f: | |
with open('InvTweaksTree.txt','w') as out: | |
reader = csv.DictReader(f) | |
out.write('<?xml version="1.0" encoding="utf-8" ?>\n<stuff treeVersion="1.7.0">\n') | |
rows = sorted((row for row in reader), key=lambda r: r['Display Name']) | |
for row in rows: | |
if any(item['Item Name'] == row['Item Name'] and row != item for item in rows): | |
out.write(' <i' + normalize(row['Display Name']) + ' id="' + row['Item Name'] + '" damage="' + row['Item meta'] + '"/>\n') | |
else: | |
out.write(' <i' + normalize(row['Display Name']) + ' id="' + row['Item Name'] + '"/>\n') | |
out.write('''</stuff>''') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment