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
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: - def filter_seq(seq, keyw='inp', no_records=2):
-
return [(seq[i], seq[i+1:i+1+no_records]) for i in range(len(seq)-no_records) if seq[i]==keyw]
-
-
seq = ['yuvaraj','sfsfsf','fasdfsf','safsaf','raj','sadfsfsf','safsafsaf','safsdfa',\
-
'inp','safsaf','sgsdg','inp','asdfsa','sgsdg','raj','adfsaf','sadfsaf','inp',\
-
'wetwt','etwtw','raj','wrqrqr']
-
-
print filter_seq(seq)
Output:
>>> [('inp', ['safsaf', 'sgsdg']), ('inp', ['asdfsa', 'sgsdg']), ('inp', ['wetwt', 'etwtw'])]
bvdet 2,851
Expert Mod 2GB
This is equivalent to the code in my previous post, but iterates to the end of the sequence: - def filter_seq1(seq, keyw='inp', no_records=2):
-
output = []
-
for i, item in enumerate(seq):
-
if item == keyw:
-
output.append((item, seq[i+1:i+1+no_records]))
-
return output
-
Test: - >>> print filter_seq(seq, 'raj', 2)
-
[('raj', ['sadfsfsf', 'safsafsaf']), ('raj', ['adfsaf', 'sadfsaf'])]
-
>>> print filter_seq1(seq, 'raj', 2)
-
[('raj', ['sadfsfsf', 'safsafsaf']), ('raj', ['adfsaf', 'sadfsaf']), ('raj', ['wrqrqr'])]
-
>>>
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 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
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
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: - >>> [('inp', ['safsaf', 'sgsdg']), ('inp', ['asdfsa', 'sgsdg']), ('inp', ['wetwt', 'etwtw'])]
Reformat output string: - print '\n'.join([item for item in [' '.join([s[0], ' '.join(s[1])]) \
-
for s in filter_seq1(seq, 'inp', 2)]])
Output: - >>> inp safsaf sgsdg
-
inp asdfsa sgsdg
-
inp wetwt etwtw
-
>>>
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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
|
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:
---------------------------
...
|
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;
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |