Python Forum
create an array of each line of text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
create an array of each line of text
#8
def split_lines(line):
    items = []
    for item in line.split('##'): # 
        if item != '#RANGE ':
            items.append(item.strip())
    return items


line_items = []
with open('raport.txt', 'r') as read_file:
    for line in read_file:
        line_items.append(split_lines(line))

for line in line_items:
    print(line)
Reply


Messages In This Thread
RE: create an array of each line of text - by DPaul - Jun-07-2020, 05:21 PM
RE: create an array of each line of text - by Yoriz - Jun-07-2020, 05:28 PM
RE: create an array of each line of text - by Yoriz - Jun-07-2020, 05:40 PM
RE: create an array of each line of text - by Yoriz - Jun-07-2020, 06:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I add comments from a text-file to an array of folders? clausneergaard 2 1,853 Feb-08-2023, 07:45 PM
Last Post: Larz60+
  Create Excel Line Chart Programmatically dee 3 1,242 Dec-30-2022, 08:44 PM
Last Post: dee
  extract only text strip byte array Pir8Radio 7 3,082 Nov-29-2022, 10:24 PM
Last Post: Pir8Radio
  Graphic line plot with matplotlib, text file in pytho khadija 2 1,444 Aug-15-2022, 12:00 PM
Last Post: khadija
  Create array of values from 2 variables paulo79 1 1,132 Apr-19-2022, 08:28 PM
Last Post: deanhystad
  Skipping line in text without Restarting Loop IdMineThat 4 1,551 Apr-05-2022, 04:23 AM
Last Post: deanhystad
  Find and delete above a certain line in text file cubangt 12 3,642 Mar-18-2022, 07:49 PM
Last Post: snippsat
  CSV to Text File and write a line in newline atomxkai 4 2,777 Feb-15-2022, 08:06 PM
Last Post: atomxkai
  Python code to read second line from CSV files and create a master CSV file sh1704 1 2,449 Feb-13-2022, 07:13 PM
Last Post: menator01
  beginner text formatting single line to column jafrost 4 3,275 Apr-28-2021, 07:03 PM
Last Post: jafrost

Forum Jump:

User Panel Messages

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