0

I am trying to open a CSV file but for some reason python cannot locate it.

import pandas as pd
base = pd.read_excel("C:\\Users\\Ricardo\\Downloads\\PRODUÇÃO_TELA_UNICA_2020_06_10.xlsb", sheet_name = "PRODUÇÃO_TELA_UNICA")
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Ricardo\\Downloads\\PRODUÇÃO_TELA_UNICA_2020_06_10.xlsb'
Red
  • 26,798
  • 7
  • 36
  • 58
  • Try renaming the file into something simple, like `file.xlbs`. – Red Jun 14 '20 at 23:48
  • try: r"C:\Users\Ricardo\Downloads\PRODUÇÃO_TELA_UNICA_2020_06_10.xlsb" (the r in front is important, see here: https://stackoverflow.com/questions/33729045/what-does-an-r-represent-before-a-string-in-python?lq=1#:~:text=r%20means%20the%20string%20will,and%20a%20lowercase%20'n'. ) – Andreas Jun 15 '20 at 00:01

1 Answers1

0

Try setting the binary file engine:

import pandas as pd
df = pd.read_excel('path_and_filename.xlsb', engine='pyxlsb')

You also might want to set pathes as raw string like this:

path = r"C:\Users\Ricardo\Downloads\PRODUÇÃO_TELA_UNICA_2020_06_10.xlsb"
df = pd.read_excel(path, engine='pyxlsb')

or even better with the os.path method, like this:

import pandas as pd
import os
path = os.path.join(r"C:\Users\Ricardo\Downloads", r"PRODUÇÃO_TELA_UNICA_2020_06_10.xlsb")
df = pd.read_excel(path, engine='pyxlsb')
Andreas
  • 8,694
  • 3
  • 14
  • 38
  • I try to use import pandas as pd import os path = os.path.join(r"C:\Users\Ricardo\Downloads", r"PRODUÇÃO_TELA_UNICA_2020_06_10.xlsb") df = pd.read_excel(path, engine='pyxlsb') but continue the same erro FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\Ricardo\Downloads/PRODUÇÃO_TELA_UNICA_2020_06_10.xlsb' – Ricardo Pinto Jun 15 '20 at 00:34
  • do you need to keep the file as xlsb? if not try save it as .xlsx. The .xlsb format might not work properly with special character like "ÇÃ". You can also try saving it as csv. Try coding it with utf-8. – Andreas Jun 15 '20 at 00:45