Reputation: 65
I have written a python script that fetches the data via API and writes it to a CSV. But now I have the problem that when I open the CSV in an Excel, everything is displayed in one column. I don't know what exactly I'm doing wrong. I have specified "sep=";" ( or "sep=",") , yet the same result is returned.
This is what my code looks like.
url = "https://api.bexio.com/2.0/article"
r = requests.get('https://api.bexio.com/2.0/article')
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "",
}
# Grab Dataframes from Bexio-API and export to CSV
response = requests.request("GET", url, headers=headers)
dic = response.json()
df = pd.DataFrame(dic)
column_map = {'intern_code': 'ProviderKey', 'stock_available_nr': 'QuantityOnStock',}
df.columns = df.columns.map(lambda x: column_map.get(x, x))
df = df[column_map.values()]
df = df[df['ProviderKey'].str.contains('MNM')]
df.to_csv('StockData.csv', index=False, sep=";")
# Send Data to FTP
ftp = FTP("")
ftp.login("","")
Output_Directory = ""
File2Send=""
ftp.cwd(Output_Directory)
with open(File2Send, "rb") as f:
ftp.storbinary('STOR ' + os.path.basename(File2Send), f)
Does anyone here have any idea what I am doing wrong?
Thanks a lot!
Update: added screenshot from csv in vi
Upvotes: 0
Views: 89