Python Forum
Print to a New Line when Appending File
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print to a New Line when Appending File
#1
How can I force appended data to a new line when writing out to an existing file please? The first line in my output file should be 943 814 2

943 814 23560581.70300000
3560591.70300000
3560601.70300000
3560611.70300000
3560621.70300000
3560631.70300000
3560641.70300000

with open(file_ls, "w") as output:
    output.write("%d %d %d" % (np.shape(kxx)[1], np.shape(kxx)[0], collapse_steps))
    for ii in np.arange((np.shape(kxx)[1])):
            print("%.8f" % (kxx[0, ii]), file=output)
Larz60+ write Mar-30-2022, 11:05 AM:
Please don't post duplicate threads.

please read (from forum help):

Posts to NOT make at all:
  • The same post in multiple sub forums. This may get you a warning, or banned based on your previous history

  • ...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with spliting line in print akbarza 3 395 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,586 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  Getting last line of each line occurrence in a file tester_V 1 871 Jan-31-2023, 09:29 PM
Last Post: deanhystad
  Print the line before the corrent line tester_V 9 1,575 Nov-18-2022, 08:39 AM
Last Post: Gribouillis
  Appending a row of data in an MS Excel file azizrasul 3 1,191 Nov-06-2022, 05:17 PM
Last Post: azizrasul
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,387 Sep-27-2022, 01:38 PM
Last Post: buran
  Saving the print result in a text file Calli 8 1,810 Sep-25-2022, 06:38 PM
Last Post: snippsat
  failing to print not matched lines from second file tester_V 14 6,108 Apr-05-2022, 11:56 AM
Last Post: codinglearner
  Find and delete above a certain line in text file cubangt 12 3,509 Mar-18-2022, 07:49 PM
Last Post: snippsat
  CSV to Text File and write a line in newline atomxkai 4 2,714 Feb-15-2022, 08:06 PM
Last Post: atomxkai

Forum Jump:

User Panel Messages

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