Check some string with timestamp is there or not in csv

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahulhere
    New Member
    • Apr 2007
    • 3

    Check some string with timestamp is there or not in csv

    Hai
    from csv file ,i want to check some string is there or not with some time stamp
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Originally posted by rahulhere
    Hai
    from csv file ,i want to check some string is there or not with some time stamp
    This finds a date with a format of dd/dd/dd (dd stands for one or more digits) in a file:
    Code:
    import re
    patt = r'\d+/\d+/\d+'
    f = open('data_file')
    for line in f:
        if re.search(patt, line):
            f.close()
            break
    print line
    
    # 295,343,83,25,FC,3,1,0,C,12/06/2007,D342,0,0,530019
    Code:
    import re
    patt = r'\d+/\d+/\d+'
    deteList = re.findall(patt, open('data_file').read())
    print dateList
    
    # ['12/06/2007']

    Comment

    Working...