-1
I created the function below to save the information of a Json to a CSV. But it saves what is being displayed in the OUTPUT. I need the information to stand next to each other and the words not to be separated...
def create_csv(shop_name, access_token):
with open('order.csv', 'a', newline='') as file:
writer = csv.writer(file, delimiter=';')
orders_list = request_products_shopify(shop_name, access_token)
for order in orders_list['orders']:
writer.writerow([order['id'], order['fulfillment_status'], order['cancelled_at'], order['cancel_reason'], order['total_discounts'], order['source_name'], order['total_tax'], order['email'], order['line_items'][0]['sku']])
if len(order['discount_applications']) > 0:
writer.writerow(order['discount_applications'][0]['type'])
else:
writer.writerow('none')
RESULT
0000000000000;;;;0.00;web;0.00;[email protected];83630.S.EX1977
a;u;t;o;m;a;t;i;c
0000000000000;;;;0.00;web;0.00;[email protected];43320.M.00PT01
n;o;n;e
0000000000000;;;;0.00;web;0.00;[email protected];43383.S.00PT01
n;o;n;e
0000000000000;;;;0.00;web;0.00;[email protected];P3006.M.00PT01
a;u;t;o;m;a;t;i;c
0000000000000;;;;0.00;web;0.00;[email protected];83590.M.EX1968
a;u;t;o;m;a;t;i;c
0000000000000;fulfilled;;;0.00;web;0.00;[email protected];43355.S.00PT01
n;o;n;e
How do I get the information to the way I need it? I don’t understand what’s going on.
You can put an example of the input to test the function?
– Augusto Vasques
I can’t... it’s confidential. I’m sorry
– viviane araujo
:) The data does not need to be true, create fictitious values that follow the actual data format. EX: Where you have
nome:Juliana Nunes,cpf:65392210006
placenome:Jurema Paliares,cpf:99990001111
and do not need to be all data just a three lines for testing.– Augusto Vasques
@hkotsubo Yes the result I would like is an additional field without the ';' between the letters.
– viviane araujo
@Augustovasques understood I’ll edit it. is that Json is giant.
– viviane araujo