Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62819
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'output': 0.05; '#if': 0.07; 'sys': 0.07; 'assuming': 0.09; 'formatting': 0.09; 'friday,': 0.09; 'issue:': 0.09; 'none)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'trailing': 0.09; 'try:': 0.09; 'python': 0.11; 'def': 0.12; 'posted': 0.15; '"%s"': 0.16; '#elif': 0.16; '.txt': 0.16; '1:09': 0.16; 'dict': 0.16; 'doesnt': 0.16; 'epoch': 0.16; 'imports': 0.16; 'key/value': 0.16; 'keys:': 0.16; 'logger': 0.16; 'pairs': 0.16; 'range.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'storing': 0.16; 'strftime': 0.16; 'tab': 0.16; 'time.time()': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'subject:need': 0.19; '>>>': 0.22; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'earlier': 0.24; 'post': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'program,': 0.31; 'code': 0.31; 'decimal': 0.31; 'file:': 0.31; 'keys': 0.31; 'pickle': 0.31; 'file': 0.32; 'thanks!': 0.32; 'run': 0.32; 'linux': 0.33; 'ago': 0.33; 'guess': 0.33; 'maybe': 0.34; 'subject:the': 0.34; 'subject:from': 0.34; 'december': 0.35; 'skip:s 30': 0.35; 'something': 0.35; 'but': 0.35; 'ubuntu': 0.36; 'should': 0.36; 'seconds': 0.37; 'unit': 0.37; 'list': 0.37; 'clear': 0.37; 'writes': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'skip:- 10': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'how': 0.40; 'commands': 0.60; 'number,': 0.60; 'new': 0.61; "you're": 0.61; 'email addr:gmail.com': 0.63; 'field': 0.63; 'here': 0.66; 'date,': 0.68; 'of:': 0.68; 'prompt': 0.68; 'smith': 0.68; 'article': 0.77; 'copy-paste': 0.84; 'fragment': 0.84; '2013': 0.98 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Ned Batchelder <ned@nedbatchelder.com> |
| Subject | Re: need to print seconds from the epoch including the millisecond |
| Date | Fri, 27 Dec 2013 13:49:54 -0500 |
| References | <e0e7da6b-5cd9-4e6d-bcca-604bd4bd8d73@googlegroups.com> <mailman.4638.1388085731.18130.python-list@python.org> <59aa73ac-e06e-4c0e-83a4-147ac42cad2e@googlegroups.com> <almarsoft.6946291744654795180@news.gmane.org> <l9ijl4$e2c$1@ger.gmane.org> <mailman.4650.1388120007.18130.python-list@python.org> <0c33b7e4-edc9-4e1e-b919-fec210c92d4a@googlegroups.com> <roy-CC46A3.11275827122013@news.panix.com> <1db0d993-9d2d-46af-9ee8-69d9250dc803@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 18.189.30.229 |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <1db0d993-9d2d-46af-9ee8-69d9250dc803@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4676.1388170207.18130.python-list@python.org> (permalink) |
| Lines | 125 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1388170207 news.xs4all.nl 2935 [2001:888:2000:d::a6]:40504 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62819 |
Show key headers only | View raw
On 12/27/13 1:09 PM, matt.doolittle33@gmail.com wrote:
> On Friday, December 27, 2013 11:27:58 AM UTC-5, Roy Smith wrote:
>> In article <0c33b7e4-edc9-4e1e-b919-fec210c92d4a@googlegroups.com>,
>>
>> matt.doolittle33@gmail.com wrote:
>>
>>
>>
>>> I am on Ubuntu 12.10. I am still working with the 2 decimal places.
>>
>>> Sometime ago i had this issue and I forget how i solved it. maybe i used
>>
>>> datetime? thanks!
>>
>>
>>
>> That's strange. Linux should give you time to the microsecond, or
>>
>> something in that range.
>>
>>
>>
>> Please post the *exact* code you're running. The code you posted
>>
>> earlier is obviously only a fragment of some larger program, so we can
>>
>> only guess what's happening. Assuming your program is in a file called
>>
>> "prog.py", run the following commands and copy-paste the output:
>>
>>
> i cant run it that way. i tried using the python prompt in terminal but got nothing. but here is all the code relevant to this issue:
> #all the imports
> import sys
> import posixpath
> import time
> from time import strftime
> from datetime import datetime
> import os
> import wx
> import cPickle as pickle
> import gnuradio.gr.gr_threading as _threading
>
>
> #the function that writes the time values
> def update(self, field_values):
>
> now = datetime.now()
>
> #logger ---------------
> # new line to write on
> self.logfile.write('\n')
> # write date, time, and seconds from the epoch
> self.logfile.write('%s\t'%(strftime("%Y-%m-%d",)))
> self.logfile.write('%s\t'%(now.strftime("%H:%M:%S",)))
> self.logfile.write('%s\t'%(time.time()))
> # list to store dictionary keys in tis order
> keys = ["duid", "nac", "tgid", "source", "algid", "kid"]
> # loop through the keys in the right order
> for k in keys:
> # get the value of the current key
> f = field_values.get(k, None)
> # if data unit has value...
> if f:
> # output the value with trailing tab
> self.logfile.write('%s\t'%(str(f)))
> # if data unit doesnt have this value print a tab
> else:
> self.logfile.write('\t')
> #end logger ----------------
>
> #if the field 'duid' == 'hdu', then clear fields
> if field_values['duid'] == 'hdu':
> self.clear()
> elif field_values['duid'] == 'ldu1':
> self.clear()
> elif field_values['duid'] == 'ldu2':
> self.clear()
> #elif field_values['duid'] == 'tdu':
> # self.clear()
> #loop through all TextCtrl fields storing the key/value pairs in k, v
> for k,v in self.fields.items():
> # get the dict value for this TextCtrl
> f = field_values.get(k, None)
> # if the value is empty then set the new value
> if f:
> v.SetValue(f)
>
> #sample output in a .txt file:
>
> 2013-12-27 12:07:33 1388164053.18
> 2013-12-27 12:07:33 1388164053.36
> 2013-12-27 12:07:33 1388164053.54
> 2013-12-27 12:07:33 1388164053.73
> 2013-12-27 12:07:33 1388164053.91
> 2013-12-27 12:07:34 1388164054.11
> 2013-12-27 12:07:34 1388164054.28
> 2013-12-27 12:07:34 1388164054.48
> 2013-12-27 12:07:34 1388164054.66
> 2013-12-27 12:07:34 1388164054.84
> 2013-12-27 12:07:37 1388164057.62
> 2013-12-27 12:07:37 1388164057.81
> 2013-12-27 12:07:37 1388164057.99
> 2013-12-27 12:07:38 1388164058.18
> 2013-12-27 12:07:38 1388164058.37
> 2013-12-27 12:07:38 1388164058.54
> 2013-12-27 12:07:38 1388164058.73
> 2013-12-27 12:07:38 1388164058.92
>
> Thanks!
>
Instead of:
"%s" % time.time()
try:
"%.6f" % time.time()
%.6f is a formatting code meaning, floating-point number, 6 decimal places.
--
Ned Batchelder, http://nedbatchelder.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-26 10:32 -0800
Re: need to print seconds from the epoch including the millisecond Dan Stromberg <drsalists@gmail.com> - 2013-12-26 11:22 -0800
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-26 14:06 -0800
Re: need to print seconds from the epoch including the millisecond Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-27 09:34 +1100
Re: need to print seconds from the epoch including the millisecond Grant Edwards <invalid@invalid.invalid> - 2014-01-02 16:23 +0000
Re: need to print seconds from the epoch including the millisecond Dave Angel <davea@davea.name> - 2014-01-02 21:41 -0500
Re: need to print seconds from the epoch including the millisecond Grant Edwards <invalid@invalid.invalid> - 2014-01-03 15:33 +0000
Re: need to print seconds from the epoch including the millisecond Chris Angelico <rosuav@gmail.com> - 2014-01-04 02:41 +1100
Re: need to print seconds from the epoch including the millisecond Dave Angel <davea@davea.name> - 2013-12-26 17:48 -0500
Re: need to print seconds from the epoch including the millisecond Terry Reedy <tjreedy@udel.edu> - 2013-12-26 20:03 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-26 20:29 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-27 07:43 -0800
Re: need to print seconds from the epoch including the millisecond Dave Angel <davea@davea.name> - 2013-12-26 23:54 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-27 07:42 -0800
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-27 07:40 -0800
Re: need to print seconds from the epoch including the millisecond Dave Angel <davea@davea.name> - 2013-12-27 11:20 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-27 11:27 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-27 10:09 -0800
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-27 13:50 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-27 13:53 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-27 20:15 -0500
Re: need to print seconds from the epoch including the millisecond Ned Batchelder <ned@nedbatchelder.com> - 2013-12-27 13:49 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-30 04:16 -0800
Re: need to print seconds from the epoch including the millisecond Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-30 14:14 +0000
Re: need to print seconds from the epoch including the millisecond Cousin Stanley <cousinstanley@gmail.com> - 2013-12-30 10:07 -0700
Re: need to print seconds from the epoch including the millisecond Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-30 17:35 +0000
Re: need to print seconds from the epoch including the millisecond Cousin Stanley <cousinstanley@gmail.com> - 2013-12-30 11:17 -0700
Re: need to print seconds from the epoch including the millisecond Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-31 05:57 +1100
Re: need to print seconds from the epoch including the millisecond Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-27 13:14 -0500
Re: need to print seconds from the epoch including the millisecond Cameron Simpson <cs@zip.com.au> - 2013-12-28 11:25 +1100
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-29 18:44 -0800
Re: need to print seconds from the epoch including the millisecond Ned Batchelder <ned@nedbatchelder.com> - 2013-12-30 07:50 -0500
Re: need to print seconds from the epoch including the millisecond Roy Smith <roy@panix.com> - 2013-12-30 09:22 -0500
Re: need to print seconds from the epoch including the millisecond Ned Batchelder <ned@nedbatchelder.com> - 2013-12-30 08:01 -0500
Re: need to print seconds from the epoch including the millisecond matt.doolittle33@gmail.com - 2013-12-30 05:40 -0800
Re: need to print seconds from the epoch including the millisecond Ned Batchelder <ned@nedbatchelder.com> - 2013-12-27 21:10 -0500
Re: need to print seconds from the epoch including the millisecond Steven D'Aprano <steve@pearwood.info> - 2013-12-28 03:50 +0000
csiph-web