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.

28 lines
599 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 = "steam_engine"
arr_loc = "../arrays/"
fl = open(title + ".txt", "rt")
rd = fl.read()
lst = rd.splitlines()
with open(arr_loc + title + ".js", "w") as output:
output.write(str(lst))
fl.close()
with open(arr_loc + title + ".js", 'r') as original:
data = original.read()
with open(arr_loc + title + ".js", 'w') as modified:
modified.write("var x = " + data + ";")