How to read a text file line by line using Python?
Reading files in python is extremely simple to do. The following is the code:
with open("/path/to/file.txt") as f: for line in f: linedata = line.split('\t') |
Very often, you may want to split each line to an array, you can use the split()
method.