Python Forum
readline inside and outside functions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
readline inside and outside functions
#1
Hi

Because of the size of files I'm working on (often more than a billion lines for example), and the number of different types of data to be recorded (specific width and so on), I've been using "with open" + "readline" (without the end "s");

The main difficulty I'm confront is that all "readline" must remain into the core of the program (and I've now more than a thousand lines to take into account all specificities even using functions when it's possible). Does it make sense to envisage continuing using "readline" into functions and then returning to the core of the program (? if so, how to proceed?

Thanks for your feedback
Reply
#2
The question is quite unclear. What prevents you from using readline() in functions?
Reply
#3
Do you mean you're using readline() inside the functions? If that is the case, you should only invoke this function in the section of the code that deals with the open file, and pass the functions the line you're reading as a parameter. Granted, it's very likely that you need to evaluate the contents of the line to determine which function to call.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pyserial Readline() conversion to array bprosman 1 1,900 Apr-11-2023, 12:44 AM
Last Post: deanhystad
  Greek letters with .readline() and tkinter KinkgOfKeks 7 1,732 Mar-24-2023, 05:13 PM
Last Post: deanhystad
Star Pyserial not reading serial.readline fast enough while using AccelStepper on Arduino MartyTinker 4 4,053 Mar-13-2023, 04:02 PM
Last Post: deanhystad
  readline.parse_and_bind() does not work in start-up script of Python interpreter zzzhhh 0 1,520 Jan-18-2022, 11:05 AM
Last Post: zzzhhh
  Python Dev suggestion: Combining line-wrap with comments inside functions NikoNiels 2 1,724 Sep-26-2020, 07:45 PM
Last Post: bowlofred
  TypeError: file must have 'read' and 'readline' attributes hobbyist 6 10,866 Jun-12-2020, 05:12 PM
Last Post: DreamingInsanity
  User defined functions inside other user defined functions WildP 1 1,939 Jan-29-2020, 04:57 PM
Last Post: Clunk_Head
  problem with readline() schlundreflex 6 4,394 Nov-06-2019, 02:22 PM
Last Post: schlundreflex
  readline() and readlines() rpaskudniak 9 30,073 Nov-21-2017, 07:39 PM
Last Post: metulburr
  Empty variable when using print before readline fstefanov 3 3,659 Oct-23-2017, 02:22 AM
Last Post: fstefanov

Forum Jump:

User Panel Messages

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