Hardware Reference
In-Depth Information
Listing Files
Your last task is to write a useful little function that lists all the files in your filing sys-
tem that are CSV files. You could just use the File Manager, but it is nice to add this
feature to your program so that you have everything you need in one place:
1. Modify the listFiles() function to use the glob.glob() function to read
in a list of all files and print them out. See Digging into the Code for an explana-
tion of how this works.
def listFiles():
print("\nFILES:")
files = glob.glob("*.csv")
for filename in files:
print(filename)
print("\n")
2. Save the program and run it again. Scan a few objects into CSV files, then choose
option 2 from the menu and make sure that they are all listed. Figure 6-12 shows
the files I created when I ran this on my computer.
FIGURE 6-12 Viewing the list of CSV files you have created
 
Search WWH ::




Custom Search