Need help Filtering Data from an API


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help Filtering Data from an API
# 22  
Old 06-26-2015
Code:
awk -F, '{n=split ($6, T, " "); print T[1]}' file

Code:
1h4m
1h21m
1h21m
1h20m
1h20m
1h19m
1h18m
1h18m

That worked....This is what I get back but how would I now sort this and show the entire line data?

Code:
awk -F'[, ]' '$6=="d" && $5>=14'

This is what I was using to sort can I combine the two into 1 line of code?
# 23  
Old 06-26-2015
Can't be. With the sample in post#12, the output of the script in post#22 should be
Code:
1
10
31
3

---------- Post updated at 21:47 ---------- Previous update was at 21:45 ----------

Look at
Code:
awk -F, '{n=split ($6, T, " "); print T[1], T[2]}' file3
1 h
10 d
31 d
3 d

You need to test if T[2] == "d" and, say, T[1]>20, and then print $0 i.e. the entire line.
# 24  
Old 06-26-2015
Code:
awk -F, '{n=split ($6, T, " "); print T[1], T[2]}' file.csv

1 h
9 d
21 h
1 h
1 h
1 h
3 d
7 d
7 d
1 h
1 h
1 h
1 h

I get these results

---------- Post updated at 02:56 PM ---------- Previous update was at 02:52 PM ----------

Code:
awk -F, '{n=split ($6, T, " "); print T[1]>2, T[2] == "d"}' file.csv
awk: line 1: syntax error at or near ,

I dont think Im using this correctly I get nothing back doing it this way. What am I missing?
# 25  
Old 06-26-2015
OK, to cut a seemingly open ended story short, try
Code:
awk -F, '{split ($6, T, " "); if (T[1] > 20 && T[2] == "d") print $0}' file
M155POD072,iOS 8.2,iPod touch 5th gen,6.3,CCQM129ZF4K1,31 d 3 h,F827939F3D33

This User Gave Thanks to RudiC For This Post:
# 26  
Old 06-26-2015
Thank you that worked great!!!

Now I get my data just like I need it. I will look over this code and see what I was missing....thank you a bunch!!! Below is what I can now get from my API and its exactly what I need.

Code:
M999PAD008 
        ==============================
        Platform : iOS 8.1
        Model : iPad Air 2
        Client Version : 6.2
        Serial Number : DMRNL7JYG5VT
        Last Connected @ : 127 d 8 h
        MAC Address : 24A074265685

 M999PDM003 
        ==============================
        Platform : iOS 7.0
        Model : iPad Mini
        Client Version : 5.7.0
        Serial Number : F4LKPLDPF196
        Last Connected @ : 451 d 0 h
        MAC Address : 689C70A61274

---------- Post updated at 03:14 PM ---------- Previous update was at 03:08 PM ----------
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read info from api website and show retrieved data

good evening, i'm still new in scripting but i'm learning every day and i'm enjoying it. so i have api website (htt p://api.nobelprize.org/v1/prize.json), i want to make a script that allows me to give it two arguments like ./test.sh 2005 physics, 2000 is for the year and physics is category... (1 Reply)
Discussion started by: kalbsghir
1 Replies

2. Shell Programming and Scripting

Filtering out the data with dates

Hi, I have some data like seen below. format : apple(hhmm mm/dd).fruit apple(2345 03/25).fruit apple(2345 05/06).fruit orange(0443 05/02).fruit orange(0345 05/05).fruit orange(2134 05/04).fruit grape(0930 04/24).fruit grape(2330 03/30).fruit I need to get the data which are... (1 Reply)
Discussion started by: jayadanabalan
1 Replies

3. Shell Programming and Scripting

Need to run an API from a script and extract fields from output of API

Hi, I need to call an API (GetUsageDetails)from inside a shell script which takes an input argument acct_nbr. The output of API will be like : <usageAccum accumId="450" accumCaptn="PM_125" inclUnits="1410.00" inclUnitsUsed="744.00" shared="true" pooled="false" prorated="false"... (1 Reply)
Discussion started by: rkrish
1 Replies

4. Shell Programming and Scripting

awk data filtering

I am trying to filter out some data with awk. If someone could help me that would be great. Below is my input file. Date: 10-JUN-12 12:00:00 B 0: 00 00 00 00 10 00 16 28 B 120: 00 00 00 39 53 32 86 29 Date: 10-JUN-12 12:00:10 B 0: 00 00 00 00 10 01 11 22 B 120: 00 00 00 29 23 32 16 29... (5 Replies)
Discussion started by: thibodc
5 Replies

5. Shell Programming and Scripting

Filtering data using AWK

Hi , i have file with delimiter as "|" and data in Double codes for all fields. how to filter data in a column like awk -F"|" '$1="asdf" {print $0}' test. ex : "asdf"|"zxcv" Thanks, Soma (1 Reply)
Discussion started by: challamsomu
1 Replies

6. Shell Programming and Scripting

help need in filtering data

Hello Gurus, Please help me out of the problem. I ve a input file as below input clock; input a; //reset all input b; //input comment output c; output d; output e; input f; //output comment I need the output as follows: \\Inputs (1 Reply)
Discussion started by: user_prady
1 Replies

7. UNIX for Dummies Questions & Answers

Filtering Data

file1 contain: (this just a small sample of data it may have thousand of lines) 1 aaa 1/01/1975 delhi 2 bbb 2/03/1977 mumbai 3 ccc 1/01/1975 mumbai 4 ddd 2/03/1977 chennai 5 aaa 1/01/1975 kolkatta 6 bbb 2/03/1977 bangalore program: nawk '{ idx= $2 SUBSEP $3 arr = (idx in arr) ?... (2 Replies)
Discussion started by: bobo
2 Replies

8. Shell Programming and Scripting

Filtering Data

Hi All, I have the below input and expected ouput. I need a code which can scan through this input file and if the number in column1 is more than 1 , it will print out the whole line, else it will output "No Re-occurrence". Can anybody help ? Input: 1 vvvvv 20 7 7 23 0 64 6 zzzzzz 11 5... (7 Replies)
Discussion started by: Raynon
7 Replies

9. UNIX for Dummies Questions & Answers

Filtering out data ...

I have following command which tells me File size in GBs which are greater than 0.01GBs recursively in a dir structure. ls -l -R | awk '{ if ($5/1073741824 >= 0.01) print $9, $5/1073741824 }' But there are some files whom I dont have enough permissions, after executing this script gives me... (1 Reply)
Discussion started by: videsh77
1 Replies
Login or Register to Ask a Question