What are we doing here?

This blog includes a series of videos and references to help new users or enthusiasts better understand how to use open source and free technology tools. The quick links includes more information for accessing many of the tools covered along with other references to learn more for taking advantage of these tools.

Click HERE to see the full list of topics covered!

Practical Programming using Python with Files

 

This tutorial demonstrates how to use Python to open and read from files in a local computer. Python is a powerful language, and the relative ease it has in opening and reading from text files makes it ideal for doing simple things (like calculating an average as showed), to more advanced (say updating 1000s of files in a single batch, or comparing different output from a research survey). There is an endless number of useful things Python can help automate, and it doesn't take a full time developer or software engineer to use.

The source code that was created is below. 

AverageNumberOfLines

For those interested as well in how to write to files, the script I used to create the 100 files with random ends is also provided. This script works by reading a sample file (Lorem Ipsum text in the example) and then randomly chops between 10 and 100 lines of text for 100 different test files. 

CreatingTextFiles

I hope it can be helpful for those interested in programming and eager to see some simple, but useful, use cases.


No comments:

Post a Comment