About 15,400 results
Open links in new tab
  1. python - How to read a file line-by-line into a list? - Stack Overflow

    How do I read every line of a file in Python and store each line as an element in a list? I want to read the file line by line and append each line to the end of the list.

  2. How should I read a file line-by-line in Python? - Stack Overflow

    Jul 19, 2012 · The title says that this question is about reading line-by-line and not reading binary files (which is very different). If you want to edit the last example to use the print-function …

  3. python - How to read a large file - line by line? - Stack Overflow

    Nov. 2022 Edit: A related question that was asked 8 months after this question has many useful answers and comments. To get a deeper understanding of python logic, do also read this …

  4. python - How to read specific lines from a file (by line number ...

    Jan 17, 2010 · I'm using a for loop to read a file, but I only want to read specific lines, say line #26 and #30. Is there any built-in feature to achieve this?

  5. python - How can I read large text files line by line, without …

    Jun 25, 2011 · I want to read a large file (>5GB), line by line, without loading its entire contents into memory. I cannot use readlines() since it creates a very large list in memory.

  6. python - How to read a file in reverse order? - Stack Overflow

    Feb 20, 2010 · How to read a file in reverse order using python? I want to read a file from last line to first line.

  7. Reading a file line by line into elements of an array in Python

    So in Ruby I can do the following: testsite_array = Array.new y=0 File.open('topsites.txt').each do |line| testsite_array[y] = line y=y+1 end How would one do that in Python?

  8. Python: read all text file lines in loop - Stack Overflow

    Jul 30, 2013 · In this case python assigns the result of the open () to a hidden, temporary variable. When the for loop ends (no matter how -- end-of-file, break or exception), the temporary …

  9. Python, Read from txt file and split data - Stack Overflow

    Nov 11, 2015 · And what I want is to define a function that reads this data into python line by line and send each line back as three variables, for this specific line above I want the function to …

  10. Reading rows from a CSV file in Python - Stack Overflow

    Nov 17, 2012 · I have a CSV file, here is a sample of what it looks like: Year: Dec: Jan: 1 50 60 2 25 50 3 30 30 4 40 20 5 10 10 I know how to read the file in and print each

Refresh