You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
546 B
Python
27 lines
546 B
Python
5 years ago
|
|
||
|
# This script convert a txt file into a js containing an array with each line of the txt
|
||
|
|
||
|
# I would like make a command from this, like > arraygen [name var] [input file] [outputfile]
|
||
|
|
||
|
title = "origin_debate"
|
||
|
|
||
|
fl = open(title + ".txt", "rt")
|
||
|
|
||
|
rd = fl.read()
|
||
|
|
||
|
lst = rd.splitlines()
|
||
|
|
||
|
with open(title + ".js", "w") as output:
|
||
|
output.write(str(lst))
|
||
|
|
||
|
fl.close()
|
||
|
|
||
|
with open(title + ".js", 'r') as original:
|
||
|
data = original.read()
|
||
|
|
||
|
with open(title + ".js", 'w') as modified:
|
||
|
modified.write("var x = " + data + ";")
|
||
|
|
||
|
|
||
|
|