Skip to content

Instantly share code, notes, and snippets.

@naoyeye
Created March 8, 2018 10:19
Show Gist options
  • Save naoyeye/a78491535e84d7c2f769e0e324e1be70 to your computer and use it in GitHub Desktop.
Save naoyeye/a78491535e84d7c2f769e0e324e1be70 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
arr = []
def save(filename, contents):
fh = open(filename, 'w')
fh.write(contents)
fh.close()
def readTxt():
n = 0
for line in open("Coupon_browns_face_1600.txt"):
n = n + 1
arr.append('\n {"expired": false, "coupon": "' + line.replace('\r\n', '') + '"}')
if (n == 800):
save('coupon.json', '{"results":[' + ','.join(arr) + '\n]}')
return
readTxt()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment