Python Forum
Read characters of line and return positions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read characters of line and return positions
#1
Hello, I am trying to pull out certain information from a huge text file because the lines are difficult to read. I can read line by line but how do I put each character in a list or array to pull out characters at certain positions? Do I use split or strip? Here is an example of a line:

0000009887465 000002250000000000089877000000000000.0002/28/202000000000.00000000000.00

I need to pull position 6 thru 13 and to get: 9887465
Then pull 27 thru 30 and 61 thru 71 to get: 225 02/28/2020

So the output would be 9887465 225 02/28/2020

If someone could point me in the right direction. Thanks!

ps. there is supposed to 9 white spaces after 65
Reply


Messages In This Thread
Read characters of line and return positions - by Gizzmo28 - Nov-04-2020, 02:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Special Characters read-write Prisonfeed 1 609 Sep-17-2023, 08:26 PM
Last Post: Gribouillis
  Python Serial: How to read the complete line to insert to MySQL? sylar 1 817 Mar-21-2023, 10:06 PM
Last Post: deanhystad
  Python code to read second line from CSV files and create a master CSV file sh1704 1 2,395 Feb-13-2022, 07:13 PM
Last Post: menator01
  Why not getting return on line #16? jahuja73 12 4,388 Feb-12-2021, 02:48 PM
Last Post: deanhystad
  read the first line in my script chubbychub 1 1,740 Nov-09-2020, 03:18 AM
Last Post: Larz60+
  Adding Sliced Positions Gizzmo28 1 1,595 Nov-05-2020, 02:46 AM
Last Post: bowlofred
  Print characters in a single line rather than one at a time hhydration 1 2,020 Oct-10-2020, 10:00 PM
Last Post: bowlofred
  Read/Sort Large text file avoiding line-by-line read using mmep or hdf5 Robotguy 0 2,044 Jul-22-2020, 08:11 PM
Last Post: Robotguy
  Remove escape characters / Unicode characters from string DreamingInsanity 5 13,670 May-15-2020, 01:37 PM
Last Post: snippsat
  How to Remove Non-ASCII Characters But Leave Line Breaks In Place? bmccollum 4 4,290 Apr-09-2020, 07:59 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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