Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact

Tips and short articles on this subject
Conversion of OSI grid references to Eastings and Northings
Reading a file multiple times - file pointers
The elegance of Python
Relative or absolute milkman
Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Python module Y110
File Handling
Exercises, examples and other material relating to training module Y110. This topic is presented on public courses Learning to program in Python, Python Programming

Python Programming - The fundamentals in depth, and an introduction to applications such as GUI design and Data Munging. This course starts at the fundamentals ...
http://www.wellho.net/course/ypfull.html  [course]
Learning to Program in Python - The fundamentals in depth, and an introduction to applications such as GUI design and Data Munging. This course starts ...
http://www.wellho.net/course/ylfull.html  [course]
When you open a file for read, you create a "file pointer" which knows where in the file you are, and each time you read from the file this advances so ...
http://www.wellho.net/mouth/1442_Rea ... nters.html  [short article]
#!/usr/local/bin/python import sys import time havevalue = 0 while havevalue < 1: try: table = input("What table to you want? ...
http://www.wellho.net/resources/ex.php4?item=y110/tablog.py  [code sample]
In both Ireland and the UK, the Ordnance survey divides down the country into a series of lettered 100km x 100km squares, represented by 1 letter (Ireland) ...
http://www.wellho.net/mouth/2011_Con ... hings.html  [short article]
If I need a little utility and I'm running a Perl course, then I'll write it in Perl. Training in Tcl ... then that's the scripting language to use for ...
http://www.wellho.net/mouth/183_The- ... ython.html  [short article]
import os import os.path import time # Build up a dictionary of timestamps content = {} for item in os.listdir('.'): content[item] = os.path.getmtime(item) ...
http://www.wellho.net/resources/ex.php4?item=y110/pinorder.py  [code sample]

How to open a file in Python and how to read it line by line into a string, or all at once, into a list. Also how to overwrite a file or add to an existing file, and how to check existing files on your file system.

This topic is presented on public courses Learning to program in Python, Python Programming

Examples from our training material
coster.py   Read whole file, report on lines matching a pattern
costhuge.py   Reading a file line by line
dmoz.py   Parsing a large file, looking for matching lines
dsa   polymorphism in action
fff   Jumping around an input file (random access)
fgfg   Improved version - program to handle data recently appended to a log file
filechex   File checks - is it a directory, when was it modified
grabpage.py   Read from a URL as is reading from a file
lost.py   Trapping a non-existant file error
n2   Find the title of a web site
pinorder.py   List a directory sorted by age of object
pstat.py   Checking whether a file exists, and things about it ...
tablog.py   File overwrite and append in python
Pictures
Writing a Python program
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from http://www.training-notes.co.uk.
Topics covered in this module
Opening and reading from files.
Writing files.
File system checks.
Reading a web page.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre. Also available is the Opentalk Forum for discussion of technical questions.


© WELL HOUSE CONSULTANTS LTD., 2009: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho