Last active
December 18, 2016 03:22
-
-
Save samvrlewis/8a1522084bc99eda7651 to your computer and use it in GitHub Desktop.
Count words in LaTeX python script
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
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
#-*- mode: python -*- | |
import subprocess | |
import os | |
import phant | |
THESIS_SECTIONS_DIR = '/Users/Sam/Dropbox/Uni/Thesis/thesis/sections/' | |
page_names = os.listdir(THESIS_SECTIONS_DIR) | |
tex_files = [THESIS_SECTIONS_DIR + page_name for page_name in page_names if '.tex' in page_name] | |
public = '0lz0p2DvR1CNJly320Nr' | |
private = 'privatekey' | |
phant = phant.Phant(public, 'words', private_key=private) | |
words = 0 | |
for tex_file in tex_files: | |
process = subprocess.Popen(['texcount', '-1', tex_file], stdout=subprocess.PIPE) | |
out, err = process.communicate() | |
words += eval(out.split()[0]) | |
phant.log(words) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment