472,986 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 software developers and data experts.

get the following output

hi
i am using Python with Activegrid and with the help of python i am getting some output from Server and i have to display particular values from that output
for example:
after splitting i get the string as
server o/p:

yuvaraj,sfsfsf,fasdfsf,safsaf,raj,sadfsfsf,safsafsaf,safsdfa,inp,safsaf,sgsdg,inp,asdfsa,sgsdg,raj,adfsaf,sadfsaf,inp,wetwt,etwtw,raj,wrqrqr

and i need to pick the values from starting inp and the following 2 records continue's that such as


inp,safsaf,sgsdg,
inp,asdfsa,sgsdg
inp,wetwt,etwtw

please reply ASAP
regards
Dec 27 '07 #1
7 1436
bvdet
2,851 Expert Mod 2GB
hi
i am using Python with Activegrid and with the help of python i am getting some output from Server and i have to display particular values from that output
for example:
after splitting i get the string as
server o/p:

yuvaraj,sfsfsf,fasdfsf,safsaf,raj,sadfsfsf,safsafsaf,safsdfa,inp,safsaf,sgsdg,inp,asdfsa,sgsdg,raj,adfsaf,sadfsaf,inp,wetwt,etwtw,raj,wrqrqr

and i need to pick the values from starting inp and the following 2 records continue's that such as


inp,safsaf,sgsdg,
inp,asdfsa,sgsdg
inp,wetwt,etwtw

please reply ASAP
regards
This will do something similar to the output you want:
Expand|Select|Wrap|Line Numbers
  1. def filter_seq(seq, keyw='inp', no_records=2):
  2.     return [(seq[i], seq[i+1:i+1+no_records]) for i in range(len(seq)-no_records) if seq[i]==keyw]
  3.  
  4. seq = ['yuvaraj','sfsfsf','fasdfsf','safsaf','raj','sadfsfsf','safsafsaf','safsdfa',\
  5.        'inp','safsaf','sgsdg','inp','asdfsa','sgsdg','raj','adfsaf','sadfsaf','inp',\
  6.        'wetwt','etwtw','raj','wrqrqr']
  7.  
  8. print filter_seq(seq)
Output:
>>> [('inp', ['safsaf', 'sgsdg']), ('inp', ['asdfsa', 'sgsdg']), ('inp', ['wetwt', 'etwtw'])]
Dec 27 '07 #2
bvdet
2,851 Expert Mod 2GB
This is equivalent to the code in my previous post, but iterates to the end of the sequence:
Expand|Select|Wrap|Line Numbers
  1. def filter_seq1(seq, keyw='inp', no_records=2):
  2.     output = []
  3.     for i, item in enumerate(seq):
  4.         if item == keyw:
  5.             output.append((item, seq[i+1:i+1+no_records]))
  6.     return output
  7.  
Test:
Expand|Select|Wrap|Line Numbers
  1. >>> print filter_seq(seq, 'raj', 2)
  2. [('raj', ['sadfsfsf', 'safsafsaf']), ('raj', ['adfsaf', 'sadfsaf'])]
  3. >>> print filter_seq1(seq, 'raj', 2)
  4. [('raj', ['sadfsfsf', 'safsafsaf']), ('raj', ['adfsaf', 'sadfsaf']), ('raj', ['wrqrqr'])]
  5. >>> 
Dec 27 '07 #3
hi
thanks for ur reply and it helpled me and now here with the same i was not able to split or replace or sub with the output:
[('inp', ['safsaf', 'sgsdg']), ('inp', ['asdfsa', 'sgsdg']), ('inp', ['wetwt', 'etwtw'])]

i need to display it as

inp, safsaf, sgsdg, inp, asdfsa, sgsdg, inp, wetwt, etwtw
without any special characters and able to be split further if possible
Reply me ASAP
regards
Dec 28 '07 #4
hi
thanks for ur reply and it helpled me and now here with the same i was not able to split or replace or sub with the output:
[('inp', ['safsaf', 'sgsdg']), ('inp', ['asdfsa', 'sgsdg']), ('inp', ['wetwt', 'etwtw'])]

i need to display it as

inp, safsaf, sgsdg, inp, asdfsa, sgsdg, inp, wetwt, etwtw
without any special characters and able to be split further if possible
Reply me ASAP
regards
hi
thanks for replying before and finally i attain my task by converting the tuple as a string and able to do all the function
str()
regards
Dec 28 '07 #5
hi
here another problem and i am trying to display the output in HTML table as

before str() it is
[inp,sdfs,adsf,inp,sadf,sdfff,inp,sadf,affaf]

and i need to display it as

fun1 fun2 fun3
inp sdfs adsf
inp sadf sdfff
inp sadf affaf


but it displays as single character as
fun1 fun2 fun3
i n p
s d f
s a d
s f i

and so on...... how to convert character to string
or how to display this format
note:from inp i need only 2 strings and it will be static
reply me ASAP
regards
Dec 28 '07 #6
bvdet
2,851 Expert Mod 2GB
hi
here another problem and i am trying to display the output in HTML table as

before str() it is
[inp,sdfs,adsf,inp,sadf,sdfff,inp,sadf,affaf]

and i need to display it as

fun1 fun2 fun3
inp sdfs adsf
inp sadf sdfff
inp sadf affaf


but it displays as single character as
fun1 fun2 fun3
i n p
s d f
s a d
s f i

and so on...... how to convert character to string
or how to display this format
note:from inp i need only 2 strings and it will be static
reply me ASAP
regards
Original output from earlier post:
Expand|Select|Wrap|Line Numbers
  1. >>> [('inp', ['safsaf', 'sgsdg']), ('inp', ['asdfsa', 'sgsdg']), ('inp', ['wetwt', 'etwtw'])]
Reformat output string:
Expand|Select|Wrap|Line Numbers
  1. print '\n'.join([item for item in [' '.join([s[0], ' '.join(s[1])]) \
  2.                                       for s in filter_seq1(seq, 'inp', 2)]])
Output:
Expand|Select|Wrap|Line Numbers
  1. >>> inp safsaf sgsdg
  2. inp asdfsa sgsdg
  3. inp wetwt etwtw
  4. >>> 
Dec 28 '07 #7
hi
thanks for ur reply's and finally i got it with ur help
actually i am new to both python and Activegrid
thanks again
regards
Dec 29 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: srikanth | last post by:
static char buf = {1,2,3,4,5,6,7,8}; printf("Address: %u : Val = %d \n",(int*)buf+1,*((int*)buf+1)); Thanks Vija
3
by: Peter Rohleder | last post by:
Hi, I'm using a style-sheet where I make use of the XPATH-"following-sibling"-expression. The part which makes problems looks similar to the following code: --------------------------- ...
8
by: aditya | last post by:
hi, Can anybody please tell me that how the following printf(...) statement works- main(){ int d=9; printf("%d",printf("%d")); return 0;
6
by: BuddyWork | last post by:
C function syntax is PvcsGetRevisionInfo2( HANDLE hArchive, /*Input */ unsigned char *filename, /*Input*/ unsigned char *revision, /*Input*/ unsigned char **author, /*Output*/ unsigned char...
4
by: zaperaj | last post by:
Im working with python2.2 on red hat linux. The following program is supposed to print decreasing numbers from an entered number till 1, each decrement being = 1 : #! usr/bin/env/python def...
1
by: sharan | last post by:
Using the expat parser (http://expat.sourceforge.net/) i have to parse the following xml file and print it on the screen in tabular format using C language. i am getting ouput serially but not in...
9
by: reachmsn | last post by:
Hi, At the url http://www.python.org/doc/essays/graphs.html there is some code by Guido Van Rossum for computing paths through a graph - I have pasted it below for reference - Let's write a...
1
by: Nikhil.S.Ketkar | last post by:
Hi, Does the following construct qualify as overloading on return type ? If not, in what way ? I overloaded the type conversion operator and used pointers to member functions. Its pretty...
5
by: naeemzi | last post by:
plz sir, solve me the following problum. #include <iostream.h> #include <windows.h> char customer_name; char description; void output(char customer_name, char movie_name, char nights,...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.