Python Forum
[solved] how to delete the 10 first lines of an ascii file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] how to delete the 10 first lines of an ascii file
#3
Hi Gribouilli,

Thanks for you hint. I just found a way using vi/vim:

import os, subprocess, sys
 
Path = os.getcwd()
AsciiFile = 'Ascii.txt'
 
vimRun = subprocess.Popen('vi ' + Path + '/' + AsciiFile + ' +1,10d -c wq ', shell = True, stdin = None, stdout = None)
# +1,10d => equivalent to ":1,10d"
# "-c" <command> => the "c" of command to be executed 
# 'stdout = None' avoid echoes
Paul
Reply


Messages In This Thread
RE: how to delete the 10 first lines of an ascii file - by paul18fr - Aug-05-2024, 07:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [SOLVED] [Beautiful Soup] Replace tag.string from another file? Winfried 2 449 May-01-2025, 03:43 PM
Last Post: Winfried
  [SOLVED] [Linux] Write file and change owner? Winfried 6 1,668 Oct-17-2024, 01:15 AM
Last Post: Winfried
  Reading an ASCII text file and parsing data... oradba4u 2 1,510 Jun-08-2024, 12:41 AM
Last Post: oradba4u
  Delete file with read-only permission, but write permission to parent folder cubei 6 25,817 Jun-01-2024, 07:22 AM
Last Post: Eleanorreo
Question [SOLVED] Correct way to convert file from cp-1252 to utf-8? Winfried 8 10,694 Feb-29-2024, 12:30 AM
Last Post: Winfried
  Loop through json file and reset values [SOLVED] AlphaInc 2 5,681 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  [SOLVED] [Debian] UnicodeEncodeError: 'ascii' codec Winfried 1 1,701 Nov-16-2022, 11:41 AM
Last Post: Winfried
  [Solved by deanhystad] Create a zip file using zipfile library DZ_Galaxy 2 5,685 Aug-17-2022, 04:57 PM
Last Post: DZ_Galaxy
  Delete multiple lines from txt file Lky 6 4,086 Jul-10-2022, 12:09 PM
Last Post: jefsummers
  Delete empty text files [SOLVED] AlphaInc 5 3,302 Jul-09-2022, 02:15 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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