Skip to content

Reading Files

Ariel Balter edited this page Aug 24, 2016 · 3 revisions

http://stackoverflow.com/questions/3277503/python-read-file-line-by-line-into-array

array = [] #declaring a list with name '**array**' 
with open(PATH,'r') as reader :
    for line in reader :
        array.append(line)

http://stackoverflow.com/questions/8009882/how-to-read-large-file-line-by-line-in-python

with open(...) as f:
    for line in f:
        <do something with line>
f = open("filename", "r")
while 

Reading File line by line in R http://stackoverflow.com/questions/12626637/reading-a-text-file-in-r-line-by-line

fileName <- "up_down.txt"
conn <- file(fileName,open="r")
linn <-readLines(conn)
for (i in 1:length(linn)){
   print(linn[i])
}
close(conn)
Clone this wiki locally