Every programmer should have a scripting language to hand. Yes, the big system may be compiled and ingeniously installed, but there are day to day tasks which should be edit and run, edit and run.
Working on Macs, with Couchbase as a database, we needed a scripted way of creating test data. Then we could quickly refine the logic and push a better document. When Rohit suggested using Python, my reaction was yes, let’s give it a go.
It worked a treat. I’m reeling from a language without curly brackets, but I will get over that. I changed my mind from uploading the files to writing them locally (for a later batch upload) and Rohit was able to comment out a line, add a file naming convention and run it again. How many thousand new documents did I want?
def generateRandomClaim(claimType, push):
surname = Randomizer.pickFrom(surnames)
firstName = ""
firstName = Randomizer.pickFrom(femaleFirstNames)
firstName = Randomizer.pickFrom(maleFirstNames)
os.system("python RandomClaimGenerator.py " + claimType + " " + firstName + " " + surname + " " + push)