0

Firstly I've saved my file on my local disc with this code:

import requests
import csv

myDailyUrls = ['https://myurl.com/something//something_01-01-2020.csv', 'https://myurl.com/something//something_01-02-2020.csv']
for x in myDailyUrls:
    urldailyLocal= os.path.basename(x)
    response = requests.get(x, verify=False)        
    with open('/path/to/my/local/folder/'+urldailyLocal, 'w') as f:
        writer = csv.writer(f)
        for line in response.iter_lines():
            writer.writerow(line.decode('utf-8').split(','))

However, when I'm trying to open my previously saved file in pandas it opens data in dataframe including all columns data in only one column:

import pandas as pd
data = '/path/to/my/local/folder/oneOfMySavedFiles.csv'
lines = pd.read_csv(data, sep=',',header=3, quoting=csv.QUOTE_NONE)

What I realised is when I moved csv file manually to my local folder then the above pandas pd.read_csv would open it as expected with 8 columns, but when used one of the saved files for which I used import csv method then it will open all in 1 column.

Could someone help with this?

Baobab1988
  • 685
  • 13
  • 33

0 Answers0