Created
June 2, 2019 17:30
-
-
Save willwangcc/84adb332a8acd898439ba4a20ee33d40 to your computer and use it in GitHub Desktop.
files (.txt) to formatted string for latex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
path = "/Users/wangzhixiang/Developer/github/all-about-will-wang/days" | |
files = [] | |
for filename in os.listdir(path): | |
files.append(filename) | |
files.sort() | |
def format(input): | |
if len(input) != 6: | |
print(input) | |
raise KeyError | |
a, b, c, d, e, f = input | |
output = "" | |
space = "\n\n\\bigskip\n" | |
output += a + space | |
output += b + space | |
output += c + space | |
output += "——" + " " + e + space | |
output += f + "\n\n\\newpage\n" | |
return output | |
for file in files: | |
with open(path+"/"+file, 'r', encoding = "utf-8") as reader: | |
temp = reader.read().split() | |
output = format(temp) | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment