banner

© 2004-19 ict4u.net

Python File Handling
TXT Files

Text files are used to store data that is unstructured ie the lines can be any length and don't have any special format or content
The end of the line has a new line character (This can't normally be seen as it's a non printing character)
Text files should always have a .txt file extension.
They look like this:

Click here to download a sample TXT file

Method Description
Read TXT by line data Read data from a text file line by line
Read TXT data Read data from a text file
Write TXT data Write data to a text file and add newline characters
Read CSV data Read data from a CSV file
CSV File read and write Read and write a CSV file using the methods from the CSV module
File exists Use the file system to see if a file exists