How the safe Data Plain Text from Python Request to CSV

0 votes
Hello

I'm new at python and trying to program something, where i grab data from a API and export the Output to a csv file. But i got problems to export the plain text.

The Code looks like that for the API-Request

#!/usr/bin/python
import requests

url = "https://api.bexio.com/2.0/article"

headers = {
    'Accept': "application/json",
    'Content-Type': "application/json",
    'Authorization': "Bearer {}",
}

response = requests.request("GET", url, headers=headers)

print(response.text)

Response:

[{"id":2,"user_id":1,"article_type_id":1,"contact_id":null,"deliverer_code":"","deliverer_name":"","deliverer_description":"","intern_code":"","intern_name":"APITEST","intern_description":"","purchase_price":null,"sale_price":null,"purchase_total":null,"sale_total":null,"currency_id":1,"tax_income_id":3,"tax_id":3,"tax_expense_id":10,"unit_id":null,"is_stock":true,"stock_id":null,"stock_place_id":null,"stock_nr":1,"stock_min_nr":10,"stock_reserved_nr":0,"stock_available_nr":1,"stock_picked_nr":0,"stock_disposed_nr":0,"stock_ordered_nr":0,"width":null,"height":null,"weight":null,"volume":null,"html_text":null,"remarks":"","delivery_price":null,"article_group_id":null},{"id":3,"user_id":1,"article_type_id":1,"contact_id":null,"deliverer_code":"","deliverer_name":"","deliverer_description":"","intern_code":"","intern_name":"WARE","intern_description":"","purchase_price":"200.000000","sale_price":"500.000000","purchase_total":null,"sale_total":null,"currency_id":1,"tax_income_id":3,"tax_id":3,"tax_expense_id":10,"unit_id":null,"is_stock":false,"stock_id":null,"stock_place_id":null,"stock_nr":0,"stock_min_nr":0,"stock_reserved_nr":0,"stock_available_nr":0,"stock_picked_nr":0,"stock_disposed_nr":0,"stock_ordered_nr":0,"width":null,"height":null,"weight":null,"volume":null,"html_text":null,"remarks":"","delivery_price":null,"article_group_id":null},

Like i wrote, i want to export the output (Response) to a csv and i don't know how to make that. I tried that with pandas but it didn't work.

Thank u all
Sep 2, 2020 in Python by SleeperSimulant
• 120 points
157 views

Hi, @ SleeperSimulant 

Are you using the Postman tool for this?

Hey, @SleeperSimulant,

How is the JSON structure coming from API?

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

How to read data from a text file using Python?

Refer to the below example where the ...READ MORE

answered May 12, 2019 in Python by Sushma
506 views
0 votes
2 answers
0 votes
2 answers
0 votes
1 answer

How to get text label from SAP using pywinauto[python]

Hi. Can you please tell me what ...READ MORE

answered Jun 28, 2018 in Python by Nietzsche's daemon
• 4,260 points
1,014 views
0 votes
3 answers

How to get the return value from a thread using python?

FWIW, the multiprocessing module has a nice interface for ...READ MORE

answered Dec 15, 2020 in Python by Roshni
• 10,420 points
53,733 views
0 votes
1 answer

How can I change the data type to string in Python?

You can use str(variablename) This is called conversion ...READ MORE

answered Dec 17, 2018 in Python by Shuvodip
150 views
0 votes
0 answers

How to read lines from compressed text files in Python

Is it easy to read a line ...READ MORE

Dec 27, 2018 in Python by Anirudh
• 2,080 points
236 views
0 votes
1 answer

How to use read a WSDL file from the file system using Python suds?

Hi, good question. It is a very simple ...READ MORE

answered Jan 21, 2019 in Python by Nymeria
• 3,520 points
3,661 views
0 votes
1 answer

How to find the value of a row in a csv file in python?

If you want to find the value ...READ MORE

answered May 20, 2019 in Python by Sanam
3,643 views
+1 vote
1 answer

How to convert records from csv to a list in Python?

If you are using Python 3.x then ...READ MORE

answered Jun 25, 2019 in Python by Arvind
• 2,980 points

edited Jun 26, 2019 by Kalgi 4,459 views