Skip to content

Commit

Permalink
Add tool for count the number of characters in a tex tile.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Ayres committed Jul 1, 2018
1 parent c39133e commit 2270464
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ A collection of [Python](https://www.python.org) utilities and tools.

- [calculate_age.py](https://github.com/lucasayres/python-tools/blob/master/tools/calculate_age.py) - Calculate age from date of birth.

- [count_characters.py](https://github.com/lucasayres/python-tools/blob/master/tools/count_characters.py) - Count the number of characters in a text file.

- [email_web_crawler.py](https://github.com/lucasayres/python-tools/blob/master/tools/email_web_crawler.py) - Web crawler for grabbing emails from a website.

- [merge_pdfs.py](https://github.com/lucasayres/python-tools/blob/master/tools/merge_pdfs.py) - Combine multiple pdfs to single pdf.
Expand Down
14 changes: 14 additions & 0 deletions tools/count_characters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
def count_characters(file):
"""Count the number of characters in a text file.
Args:
file (str): Path of a fext file.
Returns:
int: Return number of characters in a text file.
"""
with open(file) as f:
lines = f.readlines()
return len(''.join([l for l in lines]))

0 comments on commit 2270464

Please sign in to comment.