About 687,000 results
Open links in new tab
  1. How should I read a file line-by-line in Python? - Stack Overflow

    Jul 19, 2012 · @thebjorn: perhaps, but the Python 2.1 example you cited were not safe from unclosed file handler in alternate implementations. A Python 2.1 file reading that is safe from …

  2. Why does my Python code print the extra characters "" when …

    Dec 21, 2015 · Note that if you're on Python 2, you should see e.g. Python, Encoding output to UTF-8 and Convert UTF-8 with BOM to UTF-8 with no BOM in Python. You'll need to do some …

  3. python - Load data from txt with pandas - Stack Overflow

    If your text file is similar to the following (note that each column is separated from one another by a single space character ' '): 0 1.5 first 100 1 .5 thirteenth 20 2 3.0 last 3000 then it is a space …

  4. Read file content from S3 bucket with boto3 - Stack Overflow

    Mar 24, 2016 · How do I read a file if it is in folders in S3. So for eg my bucket name is A. Now A has a folder B. B has a folder C. C contains a file Readme.csv. How to read this file. Your …

  5. python - How can I read a text file into a string variable and strip ...

    Oct 18, 2016 · In Python 3.5 or later, using pathlib you can copy text file contents into a variable and close the file in one line: from pathlib import Path txt = Path('data.txt').read_text() and then …

  6. Reading specific columns from a text file in python

    Jun 20, 2001 · I have a text file which contains a table comprised of numbers e.g: 5 10 6 6 20 1 7 30 4 8 40 3 9 23 1 4 13 6 if for example I want the numbers contained only in the second …

  7. python - Read file from line 2 or skip header row - Stack Overflow

    Jan 25, 2011 · This will read the entire file into memory at once, so it's only practical if you're reading a fairly small file. – Hayden Schiff Commented Dec 4, 2018 at 3:56

  8. How to read a text file into a list or an array with Python

    Feb 4, 2013 · I am trying to read the lines of a text file into a list or array in python. I just need to be able to individually access any item in the list or array after it is created. The text file is …

  9. python reading text file - Stack Overflow

    Feb 26, 2014 · I have a text file, of which i need each column, preferably into a dictionary or list, the format is : N ID REMAIN VERS 2 2343333 bana twelve 3 3549287 moredp twelve 3 …

  10. python - How to read a file line-by-line into a list? - Stack Overflow

    # Open the file for reading. with open('my_file.txt', 'r') as infile: data = infile.read() # Read the contents of the file into memory. Now we need to focus on bringing this data into a Python List …

Refresh