Mod Artillery Names for Gun Type
Posted: Fri Dec 18, 2020 9:10 pm
# 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
# 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