Steve Jackson Games - Site Navigation
Home General Info Follow Us Search Illuminator Store Forums What's New Other Games Ogre GURPS Munchkin Our Games: Home

Go Back   Steve Jackson Games Forums > Board and Card Games > Car Wars > Car Wars Old Editions

Thread Tools Display Modes
Old 06-26-2020, 12:05 PM   #1
Join Date: Jun 2008
Default Car Wars Vehicle Designer and Python

Hi all.

This may be of no interest, in which case I apologise for wasting your bandwidth.

Over the years I have used CWVD to generate many different designs. Unless I am missing something, the CWVD needs a separate spreadsheet for each design. Over time this has become unwieldy.

As part of an up-skilling exercise I decided to see if I could do something to extract the summary text from every file in the directory automatically and append them to a single text file. I was learning python at the time (which has the advantage of being compact and cost free.

To use it, jut put your XLS or XLSM files into the directory indicated and run the programme (using your python shell). It will extract the summary text from each file (separating them with line feeds and "***" so you can find them easily) and put it into a combined.txt file (where you can reformat it as you wish). You may need to pip install "xlrd" and "os" before you can use it (depending on your python environment - Anaconda has them by default).

import xlrd
import os

directory = 'C:\python\cwvd'
for entry in os.scandir(directory):
if (entry.path.endswith(".xlsm")
or entry.path.endswith(".xls")) and entry.is_file():

book = xlrd.open_workbook(file,encoding_override="cp1251" )
book = xlrd.open_workbook(file)
sh = book.sheet_by_name("Summaries")
print("Cell a5 is {0}".format(sh.cell_value(rowx=4, colx=1)))

filen = open("c:\python\cwvd\combined.txt","a")
filen.write(str(sh.cell_value(rowx=4, colx=1)))

In pasting in the python code you need to ensure that you add in appropriate indenting (as this forum mucks up formatting). If you know any Python, this should be obvious anyway.

I hope you find it useful.

Last edited by swordtart; 06-26-2020 at 12:11 PM.
swordtart is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Fnords are Off
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT -6. The time now is 11:16 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.