Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wrapping problem
#1
I have a text file which contain header as well as data section. I want to read the data section but when i wrap the data into 582 character and check the length of data i got different length.please help me to sort out this problem. I am attaching the file
from textwrap import wrap
filepath='/media/ibaad/IBAAD/ab010120.18n'
with open(filepath) as fp:
    
    data=fp.read() # read all the data into single string
    data1=data.split('END OF HEADER') # split a string into list
    
    
    data_section=data1[1]
    data_section=data_section[1:]
    data_section=wrap(data_section,582)
    print(len(data_section[0]))
    print(len(data_section[1]))

Attached Files

.txt   ab010120.txt (Size: 114.56 KB / Downloads: 272)
Reply


Messages In This Thread
wrapping problem - by ibaad1406 - Jun-19-2019, 06:23 AM
RE: wrapping problem - by mcmxl22 - Jun-19-2019, 06:44 AM
RE: wrapping problem - by Gribouillis - Jun-19-2019, 07:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Wrapping c/c++ dll Oolongtea 2 791 Aug-25-2023, 10:35 PM
Last Post: PyDan
  How to do "fixed size" (wrapping) math in Python? AlexanderWulf 13 2,132 Jul-19-2023, 04:13 PM
Last Post: deanhystad
  xml indent SubElements (wrapping) with multiple strings ctrldan 2 1,634 Jun-09-2023, 08:42 PM
Last Post: ctrldan
  wrapping c++ library JESuh 2 1,363 Jun-16-2022, 08:18 AM
Last Post: JESuh
  Help Wrapping C Library LeftyGuitar 2 1,930 Oct-06-2019, 08:04 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

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