560 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Posted by Andy Brown on 16 October 2021
Python makes reading and writing files and looping over files and folders a joys, as this tutorial (which includes a long worked example towards the end) hopefully will demonstrate!
This video has the following accompanying files:
|Useful links.txt||Text file||Useful web links referenced|
|Best films ever.txt||Text file||List of best films to read in|
|Read in films.py||Python code||Program to read in list of films|
|Write out films.py||Python code||Program to write out worst films|
|Looping over files.py||Python code||Program to loop over files and folders|
|Listing contents of 3 files.py||Python code||Program to loop over and read in 3 files|
|1 - countries 1-10.csv||CSV file||CSV files containing countries - part 1|
|2 - countries 11-20.csv||CSV file||CSV files containing countries - part 2|
|3 - Countries 21-30.csv||CSV file||CSV files containing countries - part 3|
Click to download a zipped copy of the above files.
After watching this video, you may like to test your understanding by doing one or more of the following exercises:
|Open a file for writing, write out your details then read them back in to check||Easy|
|Open a text file, read its lines and split each to give field details for a list of Muppets||Standard|
|Loop over the files in a folder, reading the shopping data from each||Hard|
You can also download the answers to each exercise from the links above.
You can increase the size of your video to make it fill the screen like this:
Play your video (the icons shown won't appear until you do), then click on the full screen icon which appears as shown above.
When you've finished viewing a video in full screen mode, just press the Esc key to return to normal view.
To improve the quality of a video, first click on the Settings icon:
Make sure yoiu're playing your video so that the icons shown above appear, then click on this gear icon.
Choose to change the video quality:
Click as above to change your video quality.
The higher the number you choose, the better will be your video quality (but the slower the connection speed):
Don't choose the HD option shown unless your connection speed is fast enough to support it!
Is your Wise Owl speaking too slowly (or too quickly)? You can also use the Settings menu above to change your playback speed.
|When:||27 Oct 22 at 14:45|
# concatenates all excel files in one worksheet
import pandas as pd
location = r"C:\Users\munichandra.kuppani\Documents\Pandas Experiments\MonthWiseData\*.xls"
excel_files = glob.glob(location)
df1 = pd.DataFrame()
for excel_file in excel_files:
df2 = pd.read_excel(excel_file)
df1 = pd.concat([df1, df2], ignore_index=True)
i am getting this error, please give me solution :
[Running] python -u "c:\Users\munichandra.kuppani\Documents\Pandas Experiments\all_sleep_data.py"
File "c:\Users\munichandra.kuppani\Documents\Pandas Experiments\all_sleep_data.py", line 6
location = 'C:\Users\munichandra.kuppani\Documents\Pandas Experiments\MonthWiseData\*.xls'
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
[Done] exited with code=1 in 0.468 seconds
|When:||27 Oct 22 at 15:08|
I don't know the solution, but have left this post up in case anyone else has the time to answer it?
|When:||10 Feb 22 at 11:45|
Traceback (most recent call last):
File "i:\Wiseowl-Python\File handling.py", line 4, in <module>
File=open(r"C:\Users\Munichandra Kuppani\Downloads\Files needed\Best films ever.text","r")
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Munichandra Kuppani\\Downloads\\Files needed\\Best films ever.text'
if you don't mind , would you please tell me solution.
|When:||10 Feb 22 at 12:50|
Are you sure it's not called .txt, rather than .text? Otherwise it's hard to say!
25 Aytoun Street