Quantcast
Channel: Recent Gists from codeAshu
Viewing all articles
Browse latest Browse all 15

fileread.py

$
0
0
fileread.py
importjson
input_ls= []
f=open('inputTraining.txt')
forlineiniter(f):
try:
input_ls.append(json.loads(line))
exceptValueError:
printline+'is not a proper json line'
f.close()
nCount=input_ls[0]
input_ls=input_ls[1:]
iflen(input_ls) !=nCount :
print'Data is not correct, pls check!'
calvin= []
hobbes= []
forcininput_ls:
calvin.append(c.get('calvin'))
hobbes.append(c.get('hobbes'))
target= []
f=open('outputTraining.txt')
forlineiniter(f):
line=line.replace('\n','')
target.append(line)
f.close()
printlen(target)

Viewing all articles
Browse latest Browse all 15

Latest Images

Trending Articles





Latest Images