I've got a file with around 6MB of data. All of the data are written in a single line. Why is the following command taking more than 15 minutes to finish? Is it normal?
infile = open('file.txt')
outfile = open('out.txt', 'w')
for line in infile.readlines():
outfile.write(line);
Details:
I'm using Python 2.7.
Output from wc:
- newline count: 2
- word count: 3475246
- byte count: 6951140
Evaluation 1:
Reference code using in file (suggestted by Ahsanul Haque and Daewon Lee):
for line in infile:
output.write(line):
Time: 959.487 secs.
outfile
isn't opened in the correct mode for writing ...for line in infile:output.write(line)
takes how much time? It should be faster.