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
Prev   Next
# 1  
Old 04-30-2015
Need help Filtering Data from an API

Hi Everyone,

I need help on figuring out a way to filter some data that I get back from an API. Im able to get all the data that Im looking for but I would like to know a way for me to filter it better. The data that Im getting back is basically 2 rows of data as seen here.
Row 1 Row 2
Code:
ID|999MOB001|Last Contact>8 d 5 h
ID|999test13|Last Contact>2 h 0 m
ID|testipad1|Last Contact>42 m 7 s

As you can see in Row 2 I get back data that is showing the last time it was contacted.

What Im looking to get done is to get back only lines that have a specific data value that is greater than say 2 d(ays). Below is a copy of my script that Im running. So any help in what I can change to get back only the data that is older than 2 days would be helpful. From what I have been looking at I might have to use perl against my output.txt file to help sort but I wanted to see if there was a way to get this done with out using perl.

Code:
curl https:// blah blah.com/api > test.csv

sed -i '/"/d' test.csv

awk -F "\"*,\"*" '{print "ID|" $3 "|Last Contact>" $21}' test.csv > output.txt

Thanks in advance

Last edited by vgersh99; 05-01-2015 at 10:14 AM.. Reason: fixed code tags
 
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
Debian::Control::Stanza(3pm)				User Contributed Perl Documentation			      Debian::Control::Stanza(3pm)

NAME
Debian::Control::Stanza - single stanza of Debian source package control file SYNOPSIS
package Binary; use base 'Debian::Control::Stanza'; use constant fields => qw( Package Depends Conflicts ); 1; DESCRIPTION
Debian::Control::Stanza ins the base class for Debian::Control::Stanza::Source and Debian::Control::Stanza::Binary classes. FIELDS
Stanza fields are to be defined in the class method fields. Tyically this can be done like: use constant fields => qw( Foo Bar Baz ); Fields that are to contain dependency lists (as per "is_dependency_list" method below) are automatically converted to instances of the Debian::Dependencies class. CONSTRUCTOR
new new( { field => value, ... } ) Creates a new Debian::Control::Stanza object and optionally initializes it with the supplied data. The object is hashref based and tied to Tie::IxHash. You may use dashes for initial field names, but these will be converted to underscores: my $s = Debian::Control::Stanza::Source( {Build-Depends => "perl"} ); print $s->Build_Depends; METHODS
is_dependency_list($field) Returns true if $field contains a list of dependencies. By default returns true for the following fields: Build_Depends Build_Depends_Indep Build_Conflicts Build_Conflicts_Indep Depends Conflicts Enhances Replaces Breaks Pre_Depends Recommends Suggests is_comma_separated($field) Returns true if the given field is to contain a comma-separated list of values. This is used in stringification, when considering where to wrap long lines. By default the following fields are flagged to contain such lists: All fields that contain dependencies (see above) Uploaders Provides get($field) Overrides the default get method from Class::Accessor with Tie::IxHash's FETCH. set( $field, $value ) Overrides the default set method from Class::Accessor with Tie::IxHash's STORE. In the process, converts $value to an instance of the Debian::Dependencies class if $field is to contain dependency list (as determined by the "is_dependency_list" method). as_string([$width]) Returns a string representation of the object. Ready to be printed into a real debian/control file. Used as a stringification operator. Fields that are comma-separated use one line per item, except if they are like "${some:Field}", in which case they are wrapped at $widthth column. $width defaults to 80. COPYRIGHT &; LICENSE Copyright (C) 2009 Damyan Ivanov dmn@debian.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. perl v5.14.2 2012-01-15 Debian::Control::Stanza(3pm)