I have this python requirement that after login into a website using python selenium webdriver, in a particular XPath there is an embedded csv file I could download the csv file to a local folder using the below code.
content =driver.find_element_by_xpath('//*[@id=":n"]/div').click()
My requirement is to read this csv in python code and convert this as pandas dataframe directly, I tried few methods and it is not working,How this csv file can be directly converted as dataframe in python using the XPATH to use internal data processing.If this CSV is not downloaded and only can be converted as pandas using selenium method is also fine..
Error code 1 :
content1 =driver.find_element_by_xpath('//*[@id=":l"]/div').click()
content1 =pd.read_csv('content1.text')
Error code 2:
content1 =pd.read_csv('driver.find_element_by_xpath('//*[@id=":l"]/div').click()')
Note :I do not want to download and locate the file to convert it using pd_read_csv() method. Let the method be using selenium webdriver, I do not want to use requests, soup to convert a table to the data frame.
Also if the file is Excel(Xls or Xlsx) in the web embedded format how to make a dataframe.
Your support is very much appreciated. thank you!
UPDATE :Tried the below code as well still it is printing only "All/Selected to CSV File" nothing converted as pandas dataframe.
Any expert advice to resolve this issue.
content =driver.find_element_by_xpath('//*[@id=":l"]/div')
content = content.text.split('\n')
content = pd.DataFrame(content)
print(content)
This was printing "All/Selected to CSV File " Note the XPATH given is to select the CSV file.
Update2: Found the exact path from where the csv file is downloaded tried few codes still it is failing.How to read the csv without fail from this URL atleast. Note:due to security reason the URL is altered, Given here is only reference
url='https://el.hm.com/cg-in/export?EK=45002&FORMAT=2&nocache=1533623732089&TID=507686'
c=driver.get(url)
c=pd.read_csv(io.StringIO(c.decode('utf-8')))
Error :AttributeError: 'NoneType' object has no attribute 'decode'