<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<font class="Apple-style-span" face="Tahoma" size="2">Hi Gary,</font><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div style="font-family: Tahoma; font-size: 10pt; ">thank you for your answer but i'm using int in my file</div><div style="font-family: Tahoma; font-size: 10pt; "><span class="Apple-style-span" style="color: rgb(85, 85, 85); font-family: 'Segoe UI', Tahoma, Verdana, Arial, sans-serif; font-size: 12px; line-height: 15px; white-space: nowrap; "> </span></div><div style="font-family: Tahoma; "><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; ">cat /tmp/test.log</font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; ">20110612112233</font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; ">20110126145535</font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; ">20110126185500</font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; "><br></font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; "><br></font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; ">the problem is related to variable "line_log" that i use in the function, </font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; "><br></font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; "><br></font></div><div style="text-indent: 0px !important; "><span class="Apple-style-span" style="font-size: 10pt; "><div style="text-indent: 0px !important; ">file_brut = open(log_files_in, 'r')</div><div style="text-indent: 0px !important; ">line_log = file_brut.readline()</div><div style="text-indent: 0px !important; ">        while line_log:</div><div style="text-indent: 0px !important; ">                timestamp=int(time.mktime(time.strptime(line_log, "%Y%m%d%H%M%S")))</div></span></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; "><br></font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; ">Miguel</font></div><div style="font-size: 10pt; text-indent: 0px !important; "><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent: 0px !important; "><br></font></div></div><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div><br><div id="SkyDrivePlaceholder" style="font-family: Tahoma; font-size: 10pt; "></div><hr id="stopSpelling" style="font-family: Tahoma; font-size: 10pt; "><font class="Apple-style-span" face="Tahoma" size="2">Date: Mon, 13 Jun 2011 07:19:54 -0700</font><br><font class="Apple-style-span" face="Tahoma" size="2">From: gherron@islandtraining.com</font><br><font class="Apple-style-span" face="Tahoma" size="2">To: klica_sk8@hotmail.com</font><br><font class="Apple-style-span" face="Tahoma" size="2">Subject: Re: Date2Epoch script</font><br><br>

  
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML"><font class="Apple-style-span" face="Tahoma" size="2">
    
  
  
    On 06/13/2011 06:03 AM, miguel olivares varela wrote:
    </font><blockquote cite="mid:COL120-W64F6AB042603E36D1389A0DC690@phx.gbl" style="font-family: Tahoma; font-size: 10pt; ">
      <style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}

</style>
      <div style="font-family:Tahoma;font-size:10pt"><br>
      </div>
      <div style="font-family:Tahoma;font-size:10pt">Hello </div>
      <div style="font-family:Tahoma;font-size:10pt"><br>
      </div>
      <div style="font-family:Tahoma;font-size:10pt">i try to create
        a script to convert a date "YYYYmmddHHMMSS" as an UNIX
        timestamp. This is an example of my log file </div>
      <div>
        <div><font class="ecxApple-style-span" face="Tahoma" size="2"><br>
          </font></div>
        <div><font class="ecxApple-style-span" face="Tahoma" size="2">cat
            /tmp/test.log</font></div>
        <div><font class="ecxApple-style-span" face="Tahoma" size="2">20110612112233</font></div>
        <div><font class="ecxApple-style-span" face="Tahoma" size="2">20110126145535</font></div>
        <div><font class="ecxApple-style-span" face="Tahoma" size="2">20110126185500</font></div>
        <div style="font-family:Tahoma;font-size:10pt"><br>
        </div>
      </div>
      <div style="font-family:Tahoma;font-size:10pt">here is my
        code: </div>
      <div><font class="ecxApple-style-span" face="Tahoma" size="2"><br>
        </font></div>
      <div><font class="ecxApple-style-span" face="Tahoma" size="2">#!
          /usr/bin/python</font></div>
      <div><font class="ecxApple-style-span" face="Tahoma" size="2"><br>
        </font></div>
      <div><font class="ecxApple-style-span" face="Tahoma" size="2">
          <div>import os</div>
          <div>import sys</div>
          <div>import glob</div>
          <div>import re</div>
          <div>import time</div>
          <div><br>
          </div>
          <div>dir_log = "/tmp"</div>
          <div>#loop to find files log in a directory</div>
        </font><span class="ecxApple-style-span" style="font-family:Tahoma;font-size:10pt">for log_files_in  in
          glob.glob(os.path.join(dir_log, '*.log') ):</span><font class="ecxApple-style-span" face="Tahoma" size="2">
          <div>        #print log_files</div>
          <div>        file_brut = open(log_files_in, 'r')</div>
          <div>        line_log = file_brut.readline()</div>
          <div>        while line_log:</div>
          <div>               
            timestamp=int(time.mktime(time.strptime(line_log,
            "%Y%m%d%H%M%S")))</div>
        </font></div>
    </blockquote>
    <br><font class="Apple-style-span" face="Tahoma" size="2">
    Did you even bother to examine the results of any of these calls?  
    A simple test like</font><br><font class="Apple-style-span" face="Tahoma" size="2">
       >>> time.mktime(time.strptime('20110613010101',
    "%Y%m%d%H%M%S"))</font><br><font class="Apple-style-span" face="Tahoma" size="2">
       1307952061.0</font><br><font class="Apple-style-span" face="Tahoma" size="2">
    makes it clear that the thing you are passing to int() is in fact
    not an int.</font><br>
    <br><font class="Apple-style-span" face="Tahoma" size="2">
    Try removing the '.0', or use int(float(...)).</font><br>
    <br>
    <br><font class="Apple-style-span" face="Tahoma" size="2">
    Gary Herron</font><br>
    <br>
    <br>
    <br>
    <br>
    <blockquote cite="mid:COL120-W64F6AB042603E36D1389A0DC690@phx.gbl" style="font-family: Tahoma; font-size: 10pt; ">
      <div><font class="ecxApple-style-span" face="Tahoma" size="2">
          <div>                line_log=file_brut.readline()</div>
          <div>                print timestamp</div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>And here the error code: </div>
          <div>
            <div><br>
            </div>
            <div>Traceback (most recent call last):</div>
            <div>  File "formatage_lms.py", line 32, in ?</div>
            <div>    timestamp=int(time.mktime(time.strptime(line_log,
              "%Y%m%d%H%M%S")))</div>
            <div>  File "/usr/lib64/python2.4/_strptime.py", line 296,
              in strptime</div>
            <div>    raise ValueError("unconverted data remains: %s" %</div>
            <div>ValueError: unconverted data remains:</div>
          </div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>I don't know what i'm diong wrong please could you help
            me</div>
          <div><br>
          </div>
          <div>Regards</div>
          <div>Miguel</div>
          <div><br>
          </div>
          <div><br>
          </div>
        </font></div>
    </blockquote>
    <br></div>                                        </body>
</html>