github.com/pachyderm/pachyderm@v1.13.4/examples/joins/src/inner/main.py (about) 1 #!/usr/local/bin/python3 2 3 import glob, json, os, shutil, sys 4 5 store_path = glob.glob(os.path.join("/pfs/stores", "*.txt"))[0] 6 purchase_path = glob.glob(os.path.join("/pfs/purchases", "*.txt"))[0] 7 8 print("Opening store_file...: " + store_path) 9 10 with open(store_path, 'r') as store_json: 11 store = json.load(store_json) 12 zipcode = store['address']['zipcode'] 13 print("zipcode: " + zipcode) 14 15 with open("/pfs/out/"+zipcode+".txt", 'w') as location_file: 16 # Add a text separator to identify in what store the purchase was made 17 separator_line = "\nPurchase at store: "+ str(store["storeid"]) +" - "+ store["name"]+" \n" 18 location_file.write(separator_line) 19 20 print("Appending : " + purchase_path + " to:" + "/pfs/out/"+zipcode+".txt") 21 # Copy the content of the purchase file into the corresponding zipcode file 22 with open(purchase_path, 'r') as purchase_file: 23 location_file.write(purchase_file.read()) 24 25 26 27