473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 1446
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.