Python Forum
Read text file, process data and print specific output
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read text file, process data and print specific output
#4
Use .split() to split on the space (look it up). Convert to a list of numbers. Use len(the list) for your count. Loop and add to get the sum. Do this for each line in the file.
You are having trouble getting started but the loop can be done through a "list comprehension". Once you have solved it look that up to see how your loop could be condensed to a single line.
Reply


Messages In This Thread
RE: Help!!!! Simple Code - by micseydel - Feb-20-2020, 02:14 AM
RE: Read text file, process data and print specific output - by jefsummers - Feb-20-2020, 12:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation URGENT: How to plot data from text file. Trying to recreate plots from MATLAB JamieAl 4 3,608 Dec-03-2023, 06:56 AM
Last Post: Pedroski55
  dictionary output to text file (beginner) Delg_Dankil 2 1,220 Jul-12-2023, 11:45 AM
Last Post: deanhystad
  Output File ? Kessie1971 11 2,072 May-11-2023, 08:31 AM
Last Post: buran
  Print not appearing in output dgizzly 1 1,232 Oct-14-2022, 09:55 PM
Last Post: rob101
  Using regex to count specific character in file shamishd 1 1,649 Oct-01-2021, 07:33 AM
Last Post: snippsat
  Reading a text until matched string and print it as a single line cananb 1 2,052 Nov-29-2020, 01:38 PM
Last Post: DPaul
  computer science coursework, read the text please and tell me if theres any specifics sixcray 4 2,652 Nov-11-2020, 03:17 PM
Last Post: buran
  Can we store value in file if we open file in read mode? prasanthbab1234 3 2,597 Sep-26-2020, 12:10 PM
Last Post: ibreeden
  Working with text data APK 4 2,529 Aug-22-2020, 04:48 AM
Last Post: buran
  [split] how to read a specific row in CSV file ? laxmipython 2 8,908 May-22-2020, 12:19 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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