Parse online comma delimited text file in Python 3.5
<p>I guess this is a combination of two questions - read online text file and then parse the result into lists. I tried the following code, which can read the file into byte file but not able to convert into list</p>

<pre><code>import urllib
CFTC_URL = r"http://www.cftc.gov/dea/newcot/FinFutWk.txt"
CFTC_url = urllib.request.urlopen(CFTC_URL)
output = CFTC_url.read().decode('utf-8')
</code></pre>

<p>You can use standart <a href="https://docs.python.org/3.3/library/csv.html" rel="nofollow">csv</a> module with <a href="https://docs.python.org/3/library/io.html#text-i-o" rel="nofollow">StringIO</a> wrapper for file content (example with <a href="http://docs.python-requests.org/en/master/" rel="nofollow">requests</a> library for getting data):</p>

<pre><code>import requests, io, csv

CFTC_URL = r"http://www.cftc.gov/dea/newcot/FinFutWk.txt"
data = io.StringIO(requests.get(CFTC_URL).text)

dialect = csv.Sniffer().sniff(data.read(1024))
data.seek(0)
reader = csv.reader(data, dialect)
for row in reader:
    print(row)
</code></pre>

python csv urllib delimited-text