0

I have a separate system that is exporting to AVExprt.txt. In that export it has TIME combined (no space) AM/PM. How can I exclude the AM/PM from the time?

def main():

    import linecache
    filename='AVExprt.txt' 
    appendfile='AVExprt_Main.txt'
    date=linecache.getline(filename,2) 
    remove_lines= 5 

    with open(filename,'r') as file_object:
        lines = file_object.readlines()
        for i in range(remove_lines):
            del lines[0]

    with open(appendfile,'a') as file_object:   
        for line in lines:
            line = date.rstrip() + "," + line
            file_object.write(line)

if __name__== "__main__":
    main()
Sociopath
  • 13,068
  • 19
  • 47
  • 75
  • 4
    It would be helpful if you could show sample data from the file AVExprt.txt – Anurag A S Dec 28 '18 at 05:39
  • Depending of the format, have a look at https://stackoverflow.com/questions/466345/converting-string-into-datetime ; but showing us an example would be really helpful – nicolallias Dec 28 '18 at 08:43
  • 1
    Replace it with nothing: `string = string.replace('AM','')` – stovfl Dec 28 '18 at 09:12
  • Here is an example of text: "Doe, John","8675309","",9:22PM,"",6:59AM,"12/27/2018" When I import into Power Pivot Excel will not read it in time format. – MDT_PMP Dec 28 '18 at 14:23

0 Answers0