Skip to content

Instantly share code, notes, and snippets.

@codeAshu
Created February 1, 2019 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeAshu/2d708ddbe233751c594c0f3f2905488d to your computer and use it in GitHub Desktop.
Save codeAshu/2d708ddbe233751c594c0f3f2905488d to your computer and use it in GitHub Desktop.
import json
input_ls = []
f = open('inputTraining.txt')
for line in iter(f):
try:
input_ls.append(json.loads(line))
except ValueError:
print line +'is not a proper json line'
f.close()
nCount = input_ls[0]
input_ls = input_ls[1:]
if len(input_ls) != nCount :
print 'Data is not correct, pls check!'
calvin = []
hobbes = []
for c in input_ls:
calvin.append(c.get('calvin'))
hobbes.append(c.get('hobbes'))
target = []
f = open('outputTraining.txt')
for line in iter(f):
line = line.replace('\n','')
target.append(line)
f.close()
print len(target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment