I have a problem.
I want to get the content of a CSV file from an url and then parse it to an array. This is the code I have now:
import requests
import pandas as pd
import io
url="https://www.test.com/csv.php"
dataset = requests.get(url, verify=False).content
df = pd.read_csv(io.StringIO(dataset.decode('utf-8')))
data = []
for row in df: # each row is a list
data.append(row)
But when I execute this code, I only get the first row of the CSV and the values are between this -> '
['1', '4', '0']
The CSV file looks like this:
1,4,0
0,1,1
1,1,0
0,1,1
1,1,0
0,3,1
1,1,0
0,3,1
1,1,0
And I am hoping to get an array like this:
[[1,4,0],
[0,1,1],
[1,1,0],
[0,1,1],
[1,1,0],
[0,3,1],
[1,1,0],
[0,3,1],
[1,1,0]]
What am I doing wrong?
EDIT:
Using df.values gives me this:
[[0. 1. 1.]
[1. 1. 0.]
[0. 1. 1.]
...
[1. 1. 0.]
[0. 1. 1.]
[1. 3. 0.]]
But that does not seem to be correct, because the first row has to be [1,4,0]. Also I need a -> , <- as seperator