'XLSB to CSV with pandas, python
Trying to convert multiple XLSB files to CSV. Not sure what is the problem here
import os
import pandas as pd
path = r'C://Users//greencolor//Autoreport//Load_attachments//'
for filename in os.listdir(path):
if filename.startswith("PB orders"):
print(filename) #until here its working
month = pd.read_excel(filename, sheet_name="Raw data ", engine="pyxlsb")
print(month) # I get the error here
month = month[month['Sales Manager'] == 'DEVON, JOHN'] #filtering by manager
month.to_csv (path + filename + ".csv", index = None, header=True)
Error
FileNotFoundError: [Errno 2] No such file or directory: 'PB orders Dec.xlsb'
Why I get this error? print(filename) is printing all the XLSB files that name starts with PB orders
Solution 1:[1]
When you do month = pd.read_excel(filename, sheet_name="Raw data ", engine="pyxlsb") try to replace it with this:
month = pd.read_excel(path + filename, sheet_name="Raw data ", engine="pyxlsb")
This will prepend the path to your filenames in the given directory.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | neisor |
