Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading and writing files
#2
Can you list some sample contents of the input file that results in only one line of data in the new file.

Bear in mind the following
line = ',baseball\n'
print(line.endswith(',baseball'))
line = line.strip()
print(line.endswith(',baseball'))
Output:
False True
if the line end in special characters it won't match endswith.
Reply


Messages In This Thread
Reading and writing files - by JakeHoward4 - Aug-07-2019, 05:52 PM
RE: Reading and writing files - by Yoriz - Aug-07-2019, 06:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing into 2 text files from the same function paul18fr 4 1,628 Jul-28-2022, 04:34 AM
Last Post: ndc85430
  Using .hdf5 files only once they are finished writing pyhill00 7 2,720 Nov-25-2021, 06:01 PM
Last Post: pyhill00
  Fastest Way of Writing/Reading Data JamesA 1 2,138 Jul-27-2021, 03:52 PM
Last Post: Larz60+
  Reading Multiple text Files in pyhton Fatim 1 1,885 Jun-25-2021, 01:37 PM
Last Post: deanhystad
  Trouble reading files using pyexcel codebeacon 2 2,136 Feb-08-2021, 05:53 AM
Last Post: codebeacon
  Reading txt files in ssh server. therenaydin 6 4,021 Aug-06-2020, 05:17 AM
Last Post: ndc85430
  How to stop the reading of files Laplace12 4 2,312 Jul-27-2020, 04:07 PM
Last Post: Gribouillis
  How can I speed up my openpyxl program reading Excel .xlsx files? deac33 0 3,360 May-04-2020, 08:02 PM
Last Post: deac33
  Other modules for reading audio files? jedzz 0 1,569 Mar-25-2020, 11:07 PM
Last Post: jedzz
  Error With Reading Files In Directory And Calculating Values chascp 2 2,379 Feb-15-2020, 01:57 PM
Last Post: chascp

Forum Jump:

User Panel Messages

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