Created
March 3, 2017 13:30
-
-
Save mzaini30/3e32bee0e950cfbf2fd1166ee69c1668 to your computer and use it in GitHub Desktop.
Mengubah spasi menjadi bentuk tabel markdown
This file contains 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 re | |
lokasi = "/sdcard/python/regex table/" | |
enter = "\n" | |
with open(lokasi+"/input.txt", "r") as file_input,\ | |
open(lokasi+"/output.txt", "w") as file_output: | |
file_input = file_input.read() | |
file_input = re.sub(r"\t", r" | ", file_input) | |
file_input = file_input.splitlines() | |
hasil = file_input[0] | |
hasil += enter | |
hasil += "-|-" | |
hasil += enter | |
for n, x in enumerate(file_input): | |
if n != 0: | |
hasil+= x | |
hasil += enter | |
file_output.write(hasil) | |
print "done" |
This file contains 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
kucing hsvvdv hsgsgvdv satu | |
kucing hsvvdv hsgsgvdv dua | |
kucing hsvvdv hsgsgvdv tiga | |
kucing hsvvdv hsgsgvdv empat | |
kucing hsvvdv hsgsgvdv lima | |
kucing hsvvdv hsgsgvdv enam |
This file contains 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
kucing | hsvvdv | hsgsgvdv satu | |
-|- | |
kucing | hsvvdv | hsgsgvdv dua | |
kucing | hsvvdv | hsgsgvdv tiga | |
kucing | hsvvdv | hsgsgvdv empat | |
kucing | hsvvdv | hsgsgvdv lima | |
kucing | hsvvdv | hsgsgvdv enam |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment