file - Read a selected text from every line using python -
i have file contains string like
[{"resourceid": "sid-14e51598-bee7-45e0-9974-a38b07ce6892"}] [{"resourceid": "sid-a5b57deb-c024-4d89-ad99-86fc340a6742"}] [{"resourceid": "sid-3775c783-4491-44b9-904c-1763c080e9c6"}] [{"resourceid": "sid-8f636b07-3010-4d27-9e9b-08db1d25ac96"}]
i want sid-8f636b07-3010-4d27-9e9b-08db1d25ac96
every line using python. how can this?
if file example named test.txt:
#!/usr/bin/env python # -*- coding: utf-8 -*- import json open('test.txt') fh: line in fh: data = json.loads(line) print data[0]['resourceid']
Comments
Post a Comment