-1
I don’t know why you made a mistake in pycharm, how can I fix it?
I used the following libraries
import pandas as pd
import yfinance as yf
import datetime
import lxml
from kora.selenium import wd
from time import sleep
def busca_carteira_teorica(indice, espera=8):
url = f'https://sistemaswebb3-listados.b3.com.br/indexPage/day/{indice.upper()}?language=pt-br'
wd.get(url)
sleep(espera)
wd.find_element_by_id('segment').send_keys("Setor de Atuação")
sleep(espera)
wd.find_element_by_link_text("Download").click()
sleep(espera)
arquivos = !ls - 1t *.csv
return pd.read_csv(arquivos[0], sep=';', encoding='ISO-8859-1', skipfooter=2, engine='python', thousands='.', decimal=',', header=1, index_col=False)
I’d like to replace the mistake arquivos = !ls - 1t *.csv
with a code that the file downloaded in csv goes to the directory where the code file is running or in the cloud (I don’t know if I was clear). That’s all you’re making a mistake here
What should make this sentence
arquivos = !ls - 1t *.csv
???? Beholdsubprocess.Popen()
– Augusto Vasques
I am layman in python and I am trying to transfer from googlecolab to pycharm I took this video https://youtu.be/b9bU_ryC5rc?t=582 it seems that I need to put the directory of my PC, but I do not know how to do this, can help me please
– Claudio
This syntax is not typical of python, this operator
!
is a Jupyter Notebook operator, which in turn is the Google Colab engine, used to make shell command line calls. In Python you can execute a shell command withsubprocess.Popen()
. Ex: import the modulesubprocess
and replace the line that generates the error witharquivos = subprocess.Popen(['ls', '-lt', '*.csv'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
see the documentation for a more suitable use in your case.– Augusto Vasques
worked out, thanks!
– Claudio