Filter only in one element/array of Twitter JSON file -


i crawled twitter json file streaming api , got file of thousands lines of json data. however, data contains of lots of elements such "creation date", "source", "tweet text", etc. want filter word "iphone" in tweet text. however, if filter using grep unix, filters out not in "tweet text" field in "source" field. means tweet not contains word "iphone" tweeted twitter iphone stated in "source" field filtered.

is there anyway filter json in 1 field (in case "tweet text" field).

here's example of 1 json line:

{"created_at":"tue aug 20 03:48:27 +0000 2013","id":369667218608369666,"id_str":"369667218608369666","text":"@mattyb_chyeah_ yeah i'm watching him! :)","source":"\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003etwitter iphone\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":369666992334073856,"in_reply_to_status_id_str":"369666992334073856","in_reply_to_user_id":1557571363,"in_reply_to_user_id_str":"1557571363","in_reply_to_screen_name":"mattyb_chyeah_","user":{"id":1325959333,"id_str":"1325959333","name":"mattybrapstexas","screen_name":"mattybrapstexas","location":"atlanta,georgia","url":"http:\/\/www.instagram.com\/mattybrapstexas","description":"3 rt 6 mentions followed me on 4\/15\/13 6\/17\/13 maddi jane followed me on 6\/18\/13 @8:25pm! cimorelli follows pizza hut mentioned me 2 times on 7\/26\/13","protected":false,"followers_count":1095,"friends_count":426,"listed_count":8,"created_at":"thu apr 04 02:34:56 +0000 2013","favourites_count":226,"utc_offset":-14400,"time_zone":"eastern time (us & canada)","geo_enabled":false,"verified":false,"statuses_count":3447,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"c0deed","profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/378800000313651225\/afee0cc2286882eeb15f21ed7fae334a_normal.jpeg","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/378800000313651225\/afee0cc2286882eeb15f21ed7fae334a_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/1325959333\/1376759786","profile_link_color":"0084b4","profile_sidebar_border_color":"c0deed","profile_sidebar_fill_color":"ddeef6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[{"screen_name":"mattyb_chyeah_","name":"mattyb (\u2661_\u2661\u2740)","id":1557571363,"id_str":"1557571363","indices":[0,15]}]},"favorited":false,"retweeted":false,"filter_level":"medium","lang":"en" 

what using grep regex? if using 'iphone' regex yes, you'll multiple hits. can expand regex match iphone in text section before source:

grep '"text":".*iphone.*","source":' myfile.txt

will search pattern iphone after "text" before "source". ignore iphone in rest of line.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -