-1

I am trying to download a web file with this link in pandas. The issue that I am having is that most tutorials show a file that can be downloaded with a particular extension on the end, which allows for you to more easily directly download it.

This link results in the download of a text file, but it cannot be easily read with conventional methods. How can I download this file directly in pandas with this link.

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58

2 Answers2

2

Data Science Acolyte, all you have to do is this!

import pandas as pd
df = pd.read_csv('ADAMS.txt')

you can try:

df = pd.read_csv('https://www6.sos.state.oh.us/ords/f?p=VOTERFTP:DOWNLOAD::FILE:NO:2:P2_PRODUCT_NUMBER:1')
oppressionslayer
  • 6,942
  • 2
  • 7
  • 24
0

Please try this code below if it works for you:

import pandas as pd
import io
import requests

url="https://www6.sos.state.oh.us/ords/f?p=VOTERFTP:DOWNLOAD::FILE:NO:2:P2_PRODUCT_NUMBER:1"
s=requests.get(url).content
c=pd.read_csv(io.StringIO(s.decode('utf-8')))

More details here.

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
mamtach
  • 88
  • 3
  • 13