Mod Artillery Names for Gun Type

Post new scenarios and mods here to share with other gamers.

Moderator: MOD_WarintheWest

Post Reply
GeneralDad
Posts: 112
Joined: Sun Jan 07, 2018 1:22 am

Mod Artillery Names for Gun Type

Post by GeneralDad »

# Python 3 script w/ pandas library.
# Renames US and French artillery so that the gun type is in the unit name.
# eliminates the digging needed to find out what type of guns you have.
# Use with witw editor csv functions.
# Enjoy - maybe I can find time to post some modded scenario files for those
# who don't know python.
# Change filenames for the scenario you want & verify the artillery types in the
# ob file ('_ob' file, OB Types) before running.
# Takes a minute to run.
# Mod this as you wish. You may need to fix the spacing and tabs, due to the forum presentation of the text.
# Some text did not come thru the forum editor, such as i (index var) in square brackets - sorry.
# 'square bracket i close square bracket' is missing in many places after 'iloc' for example.
# If there is interest, I can post the code to GitHub to eliminate the problem.
import pandas as pd

ART_TYPES = {
1367: ' (unk)',
1368: ' (M7-105H)',
1369: ' (M12-155G)',
1370: ' (75PkH)',
1371: ' (75PkH)',
1372: ' (unk)',
1373: ' (105H)',
1374: ' (4.5G)',
1375: ' (155H)',
1376: ' (155G)',
1377: ' (8inH)',
1378: ' (8inG)',
1379: ' (240H)',
1420: ' (105H)',
1421: ' (155G)'
}

df = pd.read_csv(r'C:\Program Files (x86)\Steam\steamapps\common\Gary Grigsbys War in the West\Dat\CSV\1944-45 Campaign (D-Day Start)_unit.csv',
low_memory=False,
encoding='Windows-1252')
unit_names = df['name'].values

for i in df.index:
if df.type.iloc in ART_TYPES.keys():
if df.nat.iloc == 13:
unit_names += ART_TYPES[df.type.iloc]

elif df.nat.iloc == 22:
unit_names += ART_TYPES[df.type.iloc]

df['name'] = unit_names
df.to_csv(r'C:\Program Files (x86)\Steam\steamapps\common\Gary Grigsbys War in the West\Dat\CSV\1944-45 Campaign (D-Day Start)_unit.csv',
index=False,
encoding='Windows-1252')
print('Done!!!')
# Gen Dad
GeneralDad
Posts: 112
Joined: Sun Jan 07, 2018 1:22 am

RE: Mod Artillery Names for Gun Type

Post by GeneralDad »

Forgot the picture of the result!

Image
Attachments
art_types.jpg
art_types.jpg (28.59 KiB) Viewed 830 times
Lord13
Posts: 7
Joined: Fri Oct 13, 2023 1:30 am

Re: Mod Artillery Names for Gun Type

Post by Lord13 »

I have been looking for an excuse to learn python and you just provided it!
Post Reply

Return to “Scenario Design and Modding”