Just testing something out as practice. I have this huge CSV file online https://raw.github.com/datasets/gdp/master/data/gdp.csv And I want to read all the data and put it into a table so I can do analyse it and make tables. The code I have so far was put together using other StackOverflow questions and other websites but what seems to happen is when it's read, and then immediately printed out again it's letter by letter so I get:
['C']
['o']
['u']
['n']
['t']
['r']
['y']
[' ']
['N']
['a']
['m']
['e']
['', '']
['C']
['o']
['u']
['n']
['t']
['r']
['y']
[' ']
['C']
['o']
['d']
['e']
['', '']
['Y']
['e']
['a']
['r']
['', '']
['V']
['a']
['l']
['u']
['e']
[]
[]
['A']
['r']
['a']
['b']
[' ']
['W']
['o']
['r']
['l']
['d']
['', '']
my code is this so far:
import csv
import urllib.request
url = "https://raw.github.com/datasets/gdp/master/data/gdp.csv"
webpage = urllib.request.urlopen(url)
datareader = csv.reader(webpage.read().decode('utf-8'))
data = []
for row in datareader:
data.append(row)
for row in data:
print(row)
How can I change it so that it actually reads line by line and then even splits the line up into different variables. I did this before using
payRollNumber, salary, jobTitle, otherNames, \
surname = line.strip().split(',')
And I can apply this after I've got the rows. Any ideas?