how to read file.list python code example
Example 1: python read file in string list
# read file in a string list
with open(fileName) as f:
lineList = f.readlines()
Example 2: how to read a data file in python and build a list of files
f = open("RandomNames.txt", "r") rowList = [] for line in f.readlines(): rowList.append(line[0:-1]) print(rowList) f.close() f = open("RandomNames.txt", "r") idList = [] for line in f.readlines(): temp = line.split(",") idList.append(int(temp[0])) print(idList) f.close()