Training, Open Source Programming Languages

This is page http://www.wellho.net/resources/Y110.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
20.9.2014 - We have just updated our course layouts and descriptions and added our 2015 schedule.

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

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.


Articles and tips on this subjectupdated
3764Shell, Awk, Perl of Python?
Very frequently, IT system users find they've got a data file in one format and they need to filter it and transform it. On Linux and Unix systems, utilities such as grep and cut were the tradtions, perhaps with some awk. Perl provided a single-program replacement for shell scripts that bolted together ...
2012-06-16
 
3558Python or Lua - which should I use / learn?
"Should I learn and use Python or Lua" - a question to me. The questioner was perceptive, knowing that he shouldn't try to learn lots of languages at the same time, and that he should always limit the "basket" of languages used within his applications - in fact, he was wondering if he could select just ...
2011-12-24
(longer)
3465How can I do an FTP transfer in Python?
"If you think someone's probably done it before, they probably have .... and it's probably available to you" A good answer to many questions of the form "can I do xxxxx in Python?" Question today "can I do an FTP transfer from Python" Answer "Yes" [but I had a look around and discovered there was on ...
2011-10-05
 
3442A demonstration of how many Python facilities work together
Many of our demonstrations on the Well House Consultants site show individual features of a language - taken in isolaion to show you how they work. However, during a course we usually write further examples to show you how features work in combination to give a total result / solution to an application. On ...
2011-09-16
(longest)
3083Python - fresh examples from recent courses
During courses, I write a lot of examples in front of delegates so that the get to see both a program to perform a certain task and how that solution was reached - after all, they'll be expected to modify and write programs after the course, and just showing them the final result would only be telling ...
2010-12-13
(longer)
2870Old prices - what would the equivalent price have been in 1966?
What did a cup of tea in a café cost 10 years ago? 20 years ago? What was the rail fare from London to Manchester in 1966, 1976, 1986, 1996 and 2006? Such questions prove to be very hard to research and find answers for on the Internet. I suspect that's partly because the Internet wasn't around ...
2010-11-05
 
2282Checking robots.txt from Python
The robots.txt file - which well behaved automata check to see whether they are welcome on a web site - has two directives in its base specification ' User-Agent and DisAllow. You will find some other directives used, and you will find some sites who have a robots.txt file that has blank lines after ...
2009-07-12
 
2011Conversion of OSI grid references to Eastings and Northings
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) or 2 (UK mainland), and then measures / reports and Easting / Northing within that square. Example: ST645332 (UK, box ST, 64.5 km east, 33.2 km ...
2009-01-28
 
1442Reading a file multiple times - file pointers
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 that you get the next piece of data each time you do a read. Usually you don't see the file pointer at all - it's internal - and you think nothing ...
2007-11-27
 
183The elegance of Python
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 other requirements that day (two languages in a day is too much). And of course if I'm running Python Programming it has to be ..... MY GOODNESS - ...
2006-06-05
 
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
file_first   Short file parser
filechex   File checks - is it a directory, when was it modified
flr   Fixed Length Record to CSV
grabpage.py   Read from a URL as is reading from a file
grounds.py   Soccer grounds - Python
inflate   Inflation Calculcator - what would it have cost?
is.xyz   Inflation data - UK - annual factors
j2   using a generator to source data from a file
jdemo   json and csv handling
lost.py   Trapping a non-existant file error
majorcooker.py   Handling huge data
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 ...
sys.py   Disc space free within an application
tablog.py   File overwrite and append in python
wac1   Read file into list and process each line
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., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/Y110.html • PAGE BUILT: Thu Sep 18 11:03:17 2014 • BUILD SYSTEM: WomanWithCat