Python Forum
[split] How to write at a very specific position of a text file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] How to write at a very specific position of a text file
#1
Hello Folks,
I need to write at a very specific position of a text file and then i have to delete the same content , i have to do it in one loop ,i am having one list which is updating the name at every iteration ,can you please suggest how i can do this?
Reply
#2
I'm having a difficult time following your requirements. Reading them literally, it appears they are:

Given:
"Here is my file content."
When I replace position (for ex.) 5 (assuming zero offset) with 'x', the result should be:
"Here xs my file content."
Then I need to delete that 'x':
"Here s my file content."

I also don't follow what name is being updated.

Maybe you can provide some sample input and some pseudocode...?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I write formatted (i.e. bold, italic, change font size, etc.) text to a file? JohnJSal 12 28,205 Feb-13-2025, 04:48 AM
Last Post: tomhansky
  How to write variable in a python file then import it in another python file? tatahuft 4 966 Jan-01-2025, 12:18 AM
Last Post: Skaperen
  [SOLVED] [Linux] Write file and change owner? Winfried 6 1,570 Oct-17-2024, 01:15 AM
Last Post: Winfried
  What does .flush do? How can I change this to write to the file? Pedroski55 3 1,366 Apr-22-2024, 01:15 PM
Last Post: snippsat
  Extracting specific file from an archive tester_V 4 2,391 Jan-29-2024, 06:41 PM
Last Post: tester_V
  Last record in file doesn't write to newline gonksoup 3 1,630 Jan-22-2024, 12:56 PM
Last Post: deanhystad
  write to csv file problem jacksfrustration 11 5,293 Nov-09-2023, 01:56 PM
Last Post: deanhystad
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 3,927 Nov-09-2023, 10:56 AM
Last Post: mg24
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 2,645 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  Color a table cell based on specific text Creepy 11 5,330 Jul-27-2023, 02:48 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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