Python Forum
Last record in file doesn't write to newline
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Last record in file doesn't write to newline
#4
From the difflib documentation:
Quote:compare(a, b)
Compare two sequences of lines, and generate the delta (a sequence of lines).

Each sequence must contain individual single-line strings ending with newlines. Such sequences can be obtained from the readlines() method of file-like objects. The delta generated also consists of newline-terminated strings, ready to be printed as-is via the writelines() method of a file-like object.
It may be slightly inconvenient, but at least it tells you up front.
Reply


Messages In This Thread
RE: Last record in file doesn't write to newline - by deanhystad - Jan-22-2024, 12:56 PM

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 27,753 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 846 Jan-01-2025, 12:18 AM
Last Post: Skaperen
  [SOLVED] [Linux] Write file and change owner? Winfried 6 1,456 Oct-17-2024, 01:15 AM
Last Post: Winfried
  how to process 12 million record pymach 4 1,053 Aug-01-2024, 07:58 AM
Last Post: Pedroski55
  What does .flush do? How can I change this to write to the file? Pedroski55 3 1,278 Apr-22-2024, 01:15 PM
Last Post: snippsat
  write to csv file problem jacksfrustration 11 4,772 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,701 Nov-09-2023, 10:56 AM
Last Post: mg24
  Facing issue in python regex newline match Shr 6 5,821 Oct-25-2023, 09:42 AM
Last Post: Shr
  How do I stream and record at the same time with arducam? traderjoe 0 1,017 Oct-23-2023, 12:01 AM
Last Post: traderjoe
  How do I read and write a binary file in Python? blackears 6 23,816 Jun-06-2023, 06:37 PM
Last Post: rajeshgk

Forum Jump:

User Panel Messages

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