Python Forum
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Slicing to a file
#11
And removing the for loops in this case just displays the outfile with no text. Really stumped to what I am missing

import sys
print(" *** Truncating File Copy ***")
infile_name = input("Please enter the name of the file to copy: ")
outfile_name = input("Please enter the name of the new copy:  ")
infile = open(infile_name, 'r+', errors = 'ignore')
outfile = open(outfile_name, 'w+')
newList = infile.readlines()
def omit():
       omitline = int(input("Omit how many lines from the start:"))
       newList[omitline:]
def omit2():
       omitline2 = int(input("Omit how many lines from the end:"))
       newList[:omitline2]
omit()
omit2()
outfile.write(infile.read())
infile.close()
outfile.close()
Reply


Messages In This Thread
Slicing to a file - by Liquid_Ocelot - May-11-2017, 09:05 PM
RE: Slicing to a file - by nilamo - May-11-2017, 09:34 PM
RE: Slicing to a file - by Liquid_Ocelot - May-11-2017, 09:47 PM
RE: Slicing to a file - by nilamo - May-12-2017, 03:49 AM
RE: Slicing to a file - by Liquid_Ocelot - May-12-2017, 06:15 AM
RE: Slicing to a file - by nilamo - May-12-2017, 02:42 PM
RE: Slicing to a file - by Liquid_Ocelot - May-12-2017, 10:51 PM
RE: Slicing to a file - by ichabod801 - May-14-2017, 01:01 PM
User input slice - by Liquid_Ocelot - May-13-2017, 11:12 AM
RE: User input slice - by ichabod801 - May-13-2017, 11:50 AM
RE: User input slice - by Liquid_Ocelot - May-13-2017, 08:54 PM
RE: User input slice - by Liquid_Ocelot - May-13-2017, 10:51 PM

Forum Jump:

User Panel Messages

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