![]() (Yes, it's three lines, but you can copy-paste it as one command. 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. 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 Download csv file through python (url) Ask Question Asked 5 years, 6 months ago. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |