Skip to content

einansgar/utilities

Repository files navigation

utilities

Small python scripts for little tasks

add_line_numbers.py

A script that adds nicely-spaced line numbers to a text file, starting with 1.

Example transformation:

add_line_numbers_to_this.txt

brown
fox jumps
over
the lazy
dog and
the quick 
brown fox has
not more than
100 foxes
in the dogs
and cannot count
more than 3 horses.

output: (overwritten add_line_numbers_to_this.txt), after calling python3 add_line_numbers.py

 2 brown
 3 fox jumps
 4 over
 5 the lazy
 6 dog and
 7 the quick 
 8 brown fox has
 9 not more than
10 100 foxes
11 in the dogs
12 and cannot count
13 more than 3 horses.

remove_line_numbers.py

A script that reverses what add_line_numbers.py produces.

Call it by python3 remove_line_numbers.py remove_line_numbers_from_this.txt

sum_qgis_attribute_table_one_column.py

A script that calculates the sum of a column from the copy&paste of a QGIS attribute table that shows only one column. For whatever reason, QGIS doesn't just copy the numbers or I'm using it the wrong way.

word_counts.py

A script that identifies the frequencies of individual words used in a text file. Not case-sensitive but removes every character besides those in the Swedish alphabet so that "hello!" and "hello." are counted for "hello" and not individually (which would happen otherwise).

Want to know how often you wrote "is" in your text? Here you go!

Usage: python3 word_counts.py (and put your text in a file named doc.txt or change that reference in word_counts.py).

About

Small python scripts for little tasks

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages