Paranthaman Posted February 20, 2017 Share Posted February 20, 2017 Hi Everyone, i am a complete beginner to autoit and i am in a learning stage,so if this question looks so dumb,pls pardon me. Can anyone help me with a code where i want to take only particular values from a text and store it to array I have shared the input text which i have in below code window and i want to take only text's inside the Value tag ex: "Value":"Copy_anything_inside_this" i.e: "Value":"Jan 2016" ---->Copy Jan 2016 into a array[0,0] "Value":"5.99" --->Copy 5.99 into a array[0,1] etc expandcollapse popup{ "records":[ { "checkbox":{ "marked":false, "rowNum":"0", "sortable":false }, "0":{ "value":"Dec 2015" }, "1":{ "id":"0_0", "value":"6.38" } }, { "checkbox":{ "marked":false, "rowNum":"1", "sortable":false }, "0":{ "value":"Jan 2016" }, "1":{ "id":"0_1", "value":"5.99" } }, { "checkbox":{ "marked":false, "rowNum":"2", "sortable":false }, "0":{ "value":"Feb 2016" }, "1":{ "id":"0_2", "value":"5.73" } }, { "checkbox":{ "marked":false, "rowNum":"3", "sortable":false }, "0":{ "value":"Mar 2016" }, "1":{ "id":"0_3", "value":"6.51" } } ], "recordsReturned":12, "totalRecords":12, "pageSize":25, "startIndex":0, "sort":"Timestamp", "dir":"ASC", "pclassid":0, "metadata":[ ] } Can anyone give me a rough idea how can i do this? Link to comment Share on other sites More sharing options...
JohnOne Posted February 20, 2017 Share Posted February 20, 2017 You could search for json udf, as that looks suspiciously like json. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
iamtheky Posted February 20, 2017 Share Posted February 20, 2017 (edited) this is pretty rough #include<array.au3> _ArrayDisplay(StringRegExp(fileread("jsonstring.txt") , '".+"\:"(.+)"' , 3)) edit: if you want the labels just capture that whole group (remove the parentheses) and then split each line on the colon? Edited February 20, 2017 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
mikell Posted February 20, 2017 Share Posted February 20, 2017 (edited) May I suggest #include <Array.au3> $array = StringRegExp(Fileread("jsonstring.txt") , 'value":"([^"]*)' , 3) Local $res[UBound($array)/2][2] For $i = 0 to UBound($array)-1 step 2 For $j = 0 to 1 $res[$i/2][$j] = $array[$i+$j] Next Next _ArrayDisplay($res) Edit : Edited February 20, 2017 by mikell Link to comment Share on other sites More sharing options...
iamtheky Posted February 20, 2017 Share Posted February 20, 2017 @mikell he said "rough" answers. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Paranthaman Posted February 21, 2017 Author Share Posted February 21, 2017 10 hours ago, mikell said: May I suggest #include <Array.au3> $array = StringRegExp(Fileread("jsonstring.txt") , 'value":"([^"]*)' , 3) Local $res[UBound($array)/2][2] For $i = 0 to UBound($array)-1 step 2 For $j = 0 to 1 $res[$i/2][$j] = $array[$i+$j] Next Next _ArrayDisplay($res) Edit : Tht's it It worked as I wanted. Thanks a lot @iamtheky @mikell . Link to comment Share on other sites More sharing options...
Paranthaman Posted February 21, 2017 Author Share Posted February 21, 2017 (edited) 19 hours ago, JohnOne said: You could search for json udf, as that looks suspiciously like json. Yes that's a JSON output, will start learning JSON UDF Soon .Thanks for help Edited February 21, 2017 by Paranthaman Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now