Questions tagged [readlines]

This tag refers to the `readlines` method available on file objects in Python.

The method's schematics are below:

readlines([size:int]) -> list of strings, each a line from the file.

readlines calls the readline method repeatedly and returns a list of the lines so read. The size argument, if supplied, sets an approximate bound on the total number of bytes in the lines returned.

499 questions
-4
votes
1 answer

how to read a list of tuples in Python

all, I am learning Python, and I am wondering how to read a list of tuples, which stored in a txt file, as in the following case: I have a txt file called scores.txt with the following format: ('name1', 8) ('name2', 2) ('name3', 4) ... Now I want…
daiyue
  • 7,196
  • 25
  • 82
  • 149
-5
votes
1 answer

Python- How do I combine two outputs and merge them so what prints is a single value? python 2.7

So basically I have this code: try: fhanddate = open('AAPLprice.txt') except: print 'Could not open file - closing application' exit() stock_date = [] for line in fhanddate: p = line.strip() q = p.split(',') r = q[0:] …
coderific
  • 33
  • 1
  • 9
-5
votes
1 answer

How to read a file in R where each line is a vector of variable length ('ragged')

I want to read a file that contain many vector for example you can see below 8984 8813 8685 11629 c(8527, 11629) c(8527, 7685, 7822, 11629) c(8527, 7685, 7822, 7137, 7318, 11629) c(8527, 7685, 7822, 7137, 7318, 7063, 7075, 11629) c(8527, 7685,…
1 2 3
33
34