Hi guys, I have question about python. I mean I need a litle help.
How can I increase date from date given in file by start after midnight?
File looks like:
PROGRAMSKA SHEMA ZA PETAK, 13.12.2013.
06:00 ZMBT televoting
06:05 Madhubala, igrana serija, 138. epizoda, r.
06:50 Tajne, igrana serija, 55. epizoda, r.
07:30 Naša kuhinja
08:25 TV izlog
08:45 Bratzillaz, crtani film, 7. i 8. epizoda
08:55 ZMBT televoting
09:00 Prva dama, igrana serija, 89. epizoda
10:00 Štrumfovi, crtani film, 20. epizoda
10:30 Pčelica Maja, crtani film, 5. epizoda
10:52 Monster high, crtani film, 404. i 405. epizoda
10:55 Monsuno, crtani film, 20. epizoda
11:20 TV izlog
11:40 Tokovi novca
11:45 Vijesti
11:57 Biometeorološka prognoza
12:00 Madhubala, igrana serija, 138. epizoda, r.
12:50 Prva dama, igrana serija, 90. epizoda
13:50 Tajne, igrana serija, 55. epizoda
14:40 TV izlog
15:15 ZMBT televoting
15:20 Muzički program
15:45 ZMBT televoting
15:50 Karadayi, igrana serija, 68. epizoda
16:50 Po spisku, talk show
17:45 Krv nije voda, serijski program, 107. epizoda
18:39 International Health
18:49 Domaćica Ovako
19:00 Vijesti u 7, informativni program
19:28 Vremenska prognoza
19:29 Biometeorološka prognoza
19:31 Sport
19:38 Stanje na putevima
19:45 Tokovi novca
19:55 ZMBT televoting
20:00 Kolo sreće
20:05 Madhubala, igrana serija, 139. epizoda
21:05 ZMBT 6, show uživo
23:55 Sport centar
00:00 Dolina vukova, igrana serija, 97. i 98. epizoda
Reprizni program Hayat TV-a
01:55 ZMBT televoting
02:00 Vijesti u 7, informativni program
02:30 ZMBT 6, show
04:45 Muzički program
OK with regex i get date, and start time.
My code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import re
import time
import glob
import logging
from datetime import datetime
import datetime
def get_date_time():
# Values for date
# Example : '''YYYY-MM-DD, YYYY-DD-MM, DD MM YYYY, MM DD YYYY'''
# Example of time : '''(00:00:00, 00:00, 0:00 -- 24 Time) | (00:00, 0:00 -- AM, PM)'''
######################################################################################
#Let's add some date/time examples
######################################################################################
# TS -> 05h
# Calculating time
# Open File for checking
input_file = open('date.txt','r')
# Open Output file for writting
output = open('date_change.txt','w')
for line in input_file:
# Let's take date with regex on example --> 1/6/2014 (MM-DD-YYYY), Time --> 24h (0:00| 00:00)
if re.search(r'\d{2}.\d{2}.\d{4}', line):
line_date1 = re.findall(r'\d{2}.\d{2}.\d{4}',line)[0]
else:
if not re.search(r'\d{2}.\d{2}.\d{4}',line):
line_date = ''
print line_date
# Start
if re.search(r'\d{2}:\d{2}.*',line):
line_start = re.findall(r'\d{2}:\d{2}',line)[0]
var2 = line_start+' '+line_date1
var = line_start
if var > '00:00':
var1 = var
Date = datetime.datetime.strptime(line_date1, "%d.%m.%Y")
EndDate = Date + datetime.timedelta(days=1)
print str(EndDate) + ' '+var1
else:
Date = datetime.datetime.strptime(line_date1, "%d.%m.%Y")
print str(Date)+' '+var1
get_date_time()
Can you guys give me advice, I want automaticly to increse date after 23:59 to new date, increse for one day.
Thx, for reading this post and i hope for some good answers guys.