repl.it
@K0DYungDeku/

File read/write for HTML

Python

No description

fork
loading
Files
  • main.py
  • 1readText.txt
  • 2writeTime.txt
  • 3writeText.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#This file takes a file with times and lines and splits them in seperate files and adds <br> to match

text = open('1readText.txt','r')
arr = []
arr_2 = []


with text as f:
  while True:
    line = f.readline().replace('\n','') #pull first line
    arr.append(line.lower()) #add to arr
    arr.append("<br>") #add <br>
    line = f.readline().replace('\n','') #pull 2nd line and repeat process
    arr_2.append(line.lower()) 
    arr_2.append("<br>")
    if line == '': #break at end of file
      break

#get rid of last <br> on both
arr.pop() 
arr_2.pop() 
text.close()

#makes full strings instead of arrays
timeStampText = ''.join(arr) 
fullTextText = ''.join(arr_2)

print(arr)
print(arr_2)
print (timeStampText)
print (fullTextText)

j = open("2writeTime.txt","w")
j.write(timeStampText)
j.close()

j = open("3writeText.txt","w")
j.write(fullTextText)
j.close()
Fetching token
?