Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
writing to file
#1
Huh newbie to this!
Trying to write to a new text-file, formatted in a specific way:
The first, source, text-file is containing a list of nubmers in columns.

000123456
000123457
000123458
000123459
000123460
000123461
...........

I want to create a new list looking like this:
starts with parenthesis ("first row number" == "next row of number") and.
Like this:
(000123456 == 000123457) and
(000123458 == 000123459) and
(000123460 == 000123461).........

What is the easiest way to solve this? Started like this:

infile = open("regina.txt", "r+")
outfile = open("Regina_ID.txt", "w")
for line in infile:
infile = ( line + " == " )
outfile.write(infile)
outfile.close()

Thanks in advance!
Reply


Messages In This Thread
writing to file - by jenost - Dec-21-2019, 06:13 PM
RE: writing to file - by DreamingInsanity - Dec-21-2019, 06:53 PM
RE: writing to file - by jenost - Dec-21-2019, 07:43 PM
RE: writing to file - by snippsat - Dec-21-2019, 08:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,410 Sep-27-2022, 01:38 PM
Last Post: buran
  Writing to json file ebolisa 1 1,031 Jul-17-2022, 04:51 PM
Last Post: deanhystad
  Writing to External File DaveG 9 2,548 Mar-30-2022, 06:25 AM
Last Post: bowlofred
  Writing to file ends incorrectly project_science 4 2,724 Jan-06-2021, 06:39 PM
Last Post: bowlofred
  Writing unit test results into a text file ateestructural 3 4,792 Nov-15-2020, 05:41 PM
Last Post: ateestructural
  Writing to file in a specific folder evapa8f 5 3,470 Nov-13-2020, 10:10 PM
Last Post: deanhystad
  Failure in writing binary text to file Gigux 7 3,856 Jul-04-2020, 08:41 AM
Last Post: Gigux
  writing data to a csv-file apollo 1 2,389 Jul-03-2020, 02:28 PM
Last Post: DeaD_EyE
  Writing to File Issue Flash_Stang 3 2,551 Jun-05-2020, 05:14 AM
Last Post: Gribouillis
  Help! Formatting and Writing to a File bwdu 2 2,433 Apr-19-2020, 09:29 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