plelkpx.blogg.se

Python download csv from url
Python download csv from url









python download csv from url python download csv from url

The url offers you directly to download or open the file of. I did some research on the site but none of the solutions presented worked for me. I work on a project and I want to download a csv file from a url. (Yes, it's three lines, but you can copy-paste it as one command. Download csv file through python (url) Ask Question Asked 5 years, 6 months ago.

python download csv from url

It's hardly advertised, but yes, csv.reader can read from a list of strings.Īnd since someone else mentioned pandas, here's a one-liner to display the CSV in a console-friendly output: python3 -c 'import pandas Note the extra line beginning with lines =, the fact that urlopen is now in the urllib.request module, and print of course requires parentheses. It's now necessary to decode urlopen's response (in bytes) into a valid local encoding, so the accepted answer has to be modified slightly: import csv, urllib.request However, Python 2 is now unsupported, and this question still has good google juice for "python csv urllib", so here's an updated Python 3 solution. This question is tagged python-2.x so it didn't seem right to tamper with the original question, or the accepted answer.











Python download csv from url