User Profile

Collapse

Profile Sidebar

Collapse
maximus tee
maximus tee
Last Activity: Jan 12 '12, 02:29 PM
Joined: Dec 27 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • thanks for your guidance. RE is one of the hardest topic to understand in python.

    sorry for confusion. i tried to understand your code by doing a print. for eg:
    Code:
    p=re.compile('   " *(.*) \((.*), (.*), (.*), (.*)\)," &.*') 
    print p
    which printed:
    <_sre.SRE_Mat ch object at 0x02B5C800>

    and
    Code:
        m=p.match(line)
        print m
    ...
    See more | Go to post

    Leave a comment:


  • wow only a few lines of codes. i dont get it regular expression, it is hard.
    dont understand:
    1)p=re.compile( ' " *(.*) \((.*), (.*), (.*), (.*)\)," &.*')
    2)m=p.match(lin e), what does match line mean?
    3)m.group(i), what does it group?
    i tried to print but it only print address.

    thanks
    See more | Go to post

    Leave a comment:


  • apologies for confusion.
    general rules:
    1) the first line inside input.txt (as attached in the first post):
    -- num cell port function safe [ccell disval rslt]
    i just need num cell port function safe ccell
    however my script below couldnt get this so i skip the line. it will be great if you can show me.

    2) i'm trying to convert the line inside the input.txt
    "17 (BC_1, CLK, input, X),"...
    See more | Go to post

    Leave a comment:


  • hi, thanks for your f/back.
    would like to check whether the last line print is a typo? and also in the for loop, there is a print, ?
    i was thinking of doing:
    Code:
    for line in lines:
        a=line.split('-')[0]
        print a
        for b in a: 
            print b,
        print
    See more | Go to post

    Leave a comment:


  • thanks will relook into it.
    See more | Go to post

    Leave a comment:


  • how to use python to extract certain text in the file?

    i want to extract certain section of the text file. my input file:

    -- num cell port function safe [ccell disval rslt]
    "17 (BC_1, CLK, input, X)," &
    "16 (BC_1, OC_NEG, input, X), " &-- Merged input/
    " 8 (BC_1, D(8), input, X)," & -- cell 16 @ 1 -> Hi-Z
    " 7 (BC_1, Q(1), output3, X, 16, 1, Z)," &
    " 0 (BC_1, Q(8), output3,...
    See more | Go to post

  • maximus tee
    replied to How to convert string to long?
    i found it but the leading zeroes are being truncated.
    i want it to be: 0x0000001800000 400000000000000 000000000000000 000000000000000 000000L

    >>> array0='0000001 800000400000000 0000000000'
    >>> array1='0000000 000000000000000 0000000000'
    >>> array=array0+ar ray1
    >>> a=int(array,16)
    >>> print a
    647038726439367 532107969464256 319505531941876 229785714677657 987186688...
    See more | Go to post

    Leave a comment:


  • maximus tee
    started a topic How to convert string to long?

    How to convert string to long?

    hi,

    is there a way to convert from string to long? for eg: i want to concatenate all the arrays into data and make it same type (long) as data1.

    Code:
    a='0x'
    array0 = '00000018000004000000000000000000'
    array1 = '00000000000000000000000000000000'
    array2 = 'fe000000000000000000000000000000'
    array3 = '00000000000000000000000000ffffff'
    data = a+array0+array1+array2+array3
    print
    ...
    See more | Go to post

  • maximus tee
    replied to How to group data read from a file?
    thanks for your advice. :)
    See more | Go to post

    Leave a comment:


  • maximus tee
    replied to How to group data read from a file?
    i notice the code extracts until 128x4=512. there are 8 characters being truncated. total there are 520. how do i resolve this? tq
    See more | Go to post

    Leave a comment:


  • maximus tee
    replied to How to group data read from a file?
    sorry i didnt mention that i'm using Python 2.5 and Win XP. would like to check whether next() work for Python 2.5, i thought i read it somewhere it doesnt. anyway, i tried the code, it didnt complain any error. so i guess it works on Python 2.5 too..
    i have a more complex data file as attached and i modified the code to be:
    Code:
    f = open("test2.txt") 
    f.next() 
    dataList = [] 
    strList = [] 
    for
    ...
    See more | Go to post

    Leave a comment:


  • maximus tee
    replied to How to group data read from a file?
    the code seems to give wrong result from what i expect.
    result:
    {'ROW1': '1X1 ', 'ROW2': 'XXX0', 'ROW3': '0X X', 'ROW4': '1XX0'}

    but i'm expecting:
    ROW1=01X1
    ROW2=XXXX
    ROW3=00X1
    ROW4=11XX

    pls advise. tq
    See more | Go to post

    Leave a comment:


  • maximus tee
    replied to How to group data read from a file?
    thanks. btw, do you have any advice on a better s/w to use to debug python script. i'm only using IDLE and sometimes i get traceback error and not sure how to debug it except to that line.

    here's the code:
    Code:
    def main():
    
        new_rows = {}
        values = []
               
        f=open('test.txt')
        for line in f:
            
            values.append(line.rstrip('\n')[-1])
    ...
    See more | Go to post

    Leave a comment:


  • maximus tee
    started a topic How to group data read from a file?

    How to group data read from a file?

    hi,

    assuming i have a file that contains below data:
    cell Bit
    0 1
    1 X
    2 1
    3 0
    4 X
    5 X
    6 X
    7 X
    8 1
    9 X
    10 0
    11 0
    12 X
    13 X
    14 1
    15 1

    how can i group every 4 bits into a row? for eg:
    ROW1=01X1
    ROW2=XXXX
    ROW3=00X1
    ROW4=11XX
    ...
    See more | Go to post
    Last edited by bvdet; Feb 12 '11, 02:45 PM. Reason: Clarify title

  • maximus tee
    started a topic How to plot simple graph?

    How to plot simple graph?

    hi,

    i'm new to python. i want to read from a text file and i want to plot a scatterplot. i want to plot lane as X-axis, EyVt and EyHt as Y-axis. i'm using Python 2.5 and Win XP.
    i have a sample code but i need help on how to get python start reading column Lane, EyVt and EyHt. Pls help. tq

    eg of text file content:
    Platform: PC
    Tempt : 25
    TAP0 :0
    TAP1 :1

    +++++++++++++++ +++++++++++++++ +++++++++++++++...
    See more | Go to post

  • maximus tee
    replied to How to plot graph?
    thanks. i installed matplotlib, numpy, scipy and when running this code there was error:
    Code:
    import numpy as np 
    from numpy import cos 
    from scipy import * 
    from pylab import plot, show, ylim, yticks 
    from matplotlib import * 
    from pprint import pprint 
     
    n1 = 1.0 
    n2 = 1.5 
     
    #alpha, beta, intensity 
    data = np.array([ 
        [10,    22,     4.3],
    ...
    See more | Go to post

    Leave a comment:


  • maximus tee
    started a topic How to plot graph?

    How to plot graph?

    hi all,

    i'm new to python and this is advanced for me. is there a way to plot data with python? i want to plot EyVt, EyHt on the Y-axis and Lane on the X-axis as attached or below.
    currently i'm using Python2.5 and Win XP. thanks a lot.
    Eg:
    Platform: PC
    Tempt : 25
    TAP0 :0
    TAP1 :1
    +++++++++++++++ +++++++++++++++ +++++++++++++++
    Port Chnl Lane EyVt EyHt
    +++++++++++++++ +++++++++++++++ +++++++++++++++...
    See more | Go to post

  • How to modify font size when print out to screen?

    hi,

    i'm using Python 2.5 and Windows XP. i'm wondering whether is a way to enlarge the font size when print out to CMD window. For eg: print "Hello World". It will print out with standard size in the CMD window. Is there a way in python to enlarge the font size?

    thanks
    maximus
    See more | Go to post

  • maximus tee
    replied to How to check value in a column?
    thanks for your advice. can you pls elaborate a bit on the purpose of cnt and how the for loop works?
    i also added and else statement:
    Code:
       if "-1" in dd[key]: 
            print "Line number %s failed at column %s" % (key, dd[key].index("-1")+1)
        else:
            print "All lane PASS"
    However, this code reads each line and if it can't find -1, it'll print All lane PASS....
    See more | Go to post
    Last edited by bvdet; Jan 9 '11, 02:47 PM. Reason: Add code tags

    Leave a comment:


  • maximus tee
    replied to How to check value in a column?
    the code i had written so far didn't work in cases like when there are more than one Lane having -1. any advice on how to edit the code so that it will display all lanes fail when there is -1 value. thanks.
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...