Change the way to convert .csv into .py files
This commit is contained in:
parent
e625730293
commit
a0e48ea23c
|
@ -1,4 +1,8 @@
|
|||
def to_string(csv_filename, output_filename="world"):
|
||||
#! /usr/bin/env python3
|
||||
from sys import argv
|
||||
|
||||
|
||||
def convert_to_string(csv_filename):
|
||||
char_list = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ "
|
||||
|
||||
with open(csv_filename, "r") as file:
|
||||
|
@ -10,5 +14,7 @@ def to_string(csv_filename, output_filename="world"):
|
|||
output += char_list[char_id]
|
||||
output += "\n"
|
||||
|
||||
with open(f"{output_filename}.py", "w") as file:
|
||||
file.write(f"{output_filename}_map = r\"\"\"\n{output}\n\"\"\"")
|
||||
with open(f"{csv_filename.split(".")[0]}.py", "w") as file:
|
||||
file.write(f"{output_filename}_map = r\"\"\"\n{output}\n\"\"\"")
|
||||
|
||||
convert_to_string(*argv[1:])
|
Loading…
Reference in New Issue