Skip to content

Instantly share code, notes, and snippets.

@ShikiOkasaka
Last active September 3, 2017 08:16
Show Gist options
  • Save ShikiOkasaka/c1a42647cba3c93857ae9204bff3ba71 to your computer and use it in GitHub Desktop.
Save ShikiOkasaka/c1a42647cba3c93857ae9204bff3ba71 to your computer and use it in GitHub Desktop.
打鍵時間の測定データをテキストデータ化するためのスクリプト例
#!/usr/bin/python3
import sys
import os
from bs4 import BeautifulSoup
characters = " abcdefghijklmnopqrstuvwxyz;,./['LR"
def main():
path = 'keytime.html'
if 2 <= len(sys.argv):
path = sys.argv[1]
content = ''
with open(path) as file:
content = file.read()
soup = BeautifulSoup(content, 'html5lib')
matrix = soup.select('#matrix')[0]
rows = matrix.findAll("tr")
i = 0
for row in rows:
j = 0
for cell in row.findAll(['td']):
if 1 <= i and i <= 34 and 1 <= j and j <= 34:
print(characters[i], characters[j], ' ', cell.get_text(), sep='')
j += 1
i += 1
if __name__ == '__main__':
main()
@ShikiOkasaka
Copy link
Author

つかいかたの例:

$ ./html2txt.py keytime.notepc.html > keytime.notepc.txt

参考: https://esrille.github.io/keyboard-layout-comparison/keytime.notepc.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment