Python Forum
Creating a program that records speed in a speed trap
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a program that records speed in a speed trap
#3
error traceback, sorted out the names just stuck with subtracting
Error:
Traceback (most recent call last):   File "C:\Users\Aston Instone\Documents\College\IT BTEC\Unit 16\Assignment 2\Python Program\CurrentProgram.py", line 30, in <module>     dateTimeIn-dateTimeOut TypeError: unsupported operand type(s) for -: 'function' and 'function'
>>>

It tells me timestamp is needed so I enter it than says timestamp is not defined?
from datetime import datetime
#Function to convert date from string to dateTime
def dateTimeIn(timestamp):
    dateTimeIn = datetime.strptime(strTimeIn, "%d/%m/%Y %H:%M:%S")
    return dateTimeIn
def dateTimeOut(timestamp):
    dateTimeOut = datetime.strptime(strTimeOut, "%d/%m/%Y %H:%M:%S")
    return dateTimeOut
   

#Main Program   
myFileIn=open("CameraIn.txt","rt")
myFileOutput=open("Output.txt","rt")
for lineIn in myFileIn:
    lineIn=myFileIn.readline()
    theListIn=lineIn.split(",")
    regIn=theListIn[0]
    strTimeIn=theListIn[1]
    myFileOut=open("CameraOut.txt","rt")
    for lineOut in myFileOut:
        lineOut=myFileOut.readline()
        theListOut=lineOut.split(",")
        regOut=theListOut[0]
        strTimeOut=theListOut[1]
        if regIn==regOut:
            dateTimeIn(timestamp)-dateTimeOut(timestamp)
Error:
Traceback (most recent call last):   File "C:\Users\Aston Instone\Documents\College\IT BTEC\Unit 16\Assignment 2\Python Program\CurrentProgram.py", line 30, in <module>     dateTimeIn(timestamp)-dateTimeOut(timestamp) NameError: name 'timestamp' is not defined
>>>

I have to get the timestamp from the file and I want it to do this for every timestamp that shows that the car is speeding?
Reply


Messages In This Thread
RE: Creating a program that records speed in a speed trap - by astonavfc - Nov-01-2016, 05:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Suggestion on how to speed up this code? sawtooth500 1 263 May-04-2024, 07:13 PM
Last Post: sawtooth500
  Concurrent futures threading running at same speed as non-threading billykid999 13 2,021 May-03-2023, 08:22 AM
Last Post: billykid999
  itertools and amazing speed Pedroski55 8 2,145 Nov-11-2022, 01:20 PM
Last Post: Gribouillis
  How to speed up nested cycles? alexfrol86 3 1,616 Mar-25-2022, 06:19 AM
Last Post: deanhystad
  How to know coming snmp trap version in python pysnmp? ilknurg 0 2,654 Jan-31-2022, 12:16 PM
Last Post: ilknurg
  Increase the speed of a python loop over a pandas dataframe mcva 0 1,352 Jan-21-2022, 06:24 PM
Last Post: mcva
  Speed up code with second process help samuelbachorik 0 1,441 Sep-04-2021, 09:31 AM
Last Post: samuelbachorik
  Random coordinate generator speed improvement saidc 0 2,085 Aug-01-2021, 11:09 PM
Last Post: saidc
  creating simplex tableau pivot program easy or difficult for a beginner in Python? alex_0 2 2,635 Mar-31-2021, 03:39 AM
Last Post: Larz60+
  How to create a speed limiter for a car Tyrel 3 2,980 Feb-24-2021, 09:32 AM
Last Post: Tyrel

Forum Jump:

User Panel Messages

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