Created
February 1, 2019 09:06
-
-
Save codeAshu/2d708ddbe233751c594c0f3f2905488d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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