Python Forum
Batch job from epoch to human time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch job from epoch to human time
#1
Hi everyone, pretty new to python. I am a voice engineer by trade, but am trying to learn, as automation is huge in my field. That being said here is my question. I have a report that dumps out data in epoch time. I have utilized this code to get it translated properly to CST. Although, with a report that has 5200 of these, wondering if there is a batch way to run this for all?

>>> import time
>>> epoch = 1515998448
>>> time.strftime("%a, %d %b %Y %H:%M:%S %Z", time.localtime(epoch))
'Mon, 15 Jan 2018 00:40:48 Central Standard Time'
Any help is greatly appreciated!

thanks,

Jeff
Reply
#2
what format is the report source data in? looking for .csv, .json, .txt PostgreSQL, MySQL, etc.
what software produces the report.
It's possible that the reporting software can convert the time.
Or, the data can be loaded and modified.
It all depends on source format and reporting package,
Reply
#3
.txt primarily, i converted it over to .csv. Easier to read for customers of course.

Call manager is usually linux based on the backend, but Cisco locks it down so you cannot do anything. Even their own staff have to put in requests to get root access. Pretty crazy. So not sure if there is an easy way?

The CDR (call detail record) that it pulls from is so simplistic also, doesn't allow me to manipulate the time at all. Just gives you a date range, then exports out in only epoch. Let me know if i'm missing any information you are looking for.
Reply
#4
I know exactly what you are talking about (CDR) as my background is telecommunications.
At some point, there needs to be translation.
Is the conversion to .csv just an export, or do you manipulate the data to get there?
Reply
#5
(Feb-08-2018, 07:20 PM)Larz60+ Wrote: I know exactly what you are talking about (CDR) as my background is telecommunications.
At some point, there needs to be translation.
Is the conversion to .csv just an export, or do you manipulate the data to get there?

Yeah i'm sorry this got put on the backburner. I did utilize an epoch to human time converter and it went to GMT, although the client was too lazy to do the math Wink to central time. So yes i export it, open it up in .CSV and from there would love to see if there is a batch way to change over 5k fields from GMT to CST or just in general to CST from what CDR dumps out.

I was told by another friend general expressions might do that? Not sure, but appreciate any help!

thanks,

Jeff
Reply
#6
One more time, what is the format of the .csv file.
if on Linux, type:
head -10 filename.csv
on windows, type:
type filename.csv | more
ctrl-c after first page.
in either case, show the 10 lines.
Reply
#7
Sorry, it would be done on a windows pc, utilizing a .csv file. I will try that out though myself and see if i can get it going. I truly appreciate the help!

thanks,

Jeff

Initially a text file, i just rename the extension to .csv so it will open in excel. Forgot that portion.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] Epoch timestamp without milliseconds? Winfried 5 3,003 Jan-27-2023, 04:35 PM
Last Post: deanhystad
  Human Sorting (natsort) does not work [SOLVED] AlphaInc 2 1,133 Jul-04-2022, 10:21 AM
Last Post: AlphaInc
  batch file for running python scipt in Windows shell MaartenRo 2 1,893 Jan-21-2022, 02:36 PM
Last Post: MaartenRo
  sorting alphanumeric values in a human way idiotonboarding 3 2,620 Jan-22-2021, 05:57 PM
Last Post: idiotonboarding
  Stumped by my own code (ratio & epoch-time calculation). MvGulik 2 2,139 Dec-30-2020, 12:04 AM
Last Post: MvGulik
  How to run script from batch file? jmair 1 4,270 Oct-12-2020, 04:29 PM
Last Post: jmair
  python script to Batch File biprabu 1 2,053 Sep-09-2020, 01:49 PM
Last Post: jefsummers
  Writing a function to calculate time range in Unix Epoch Time t4keheart 2 3,009 Jul-15-2020, 01:55 AM
Last Post: t4keheart
  changing code to work on a batch of images within a folder Afrodizzyjack 2 2,051 May-12-2020, 08:56 PM
Last Post: Afrodizzyjack
  Parse Binary Data File and convert Epoch Time drdevereaux 1 3,185 May-16-2019, 01:56 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020