Computer Science, asked by vedsanisahu9509, 9 days ago

Create 3 sample records in JSON, and CSV format storing details about grocery products. You must have at least 3 fields per record.
anyone know i can do this (subject is database)

Answers

Answered by chandan454380
0

Answer:

3 sample record in JSON and CSV format is given by explanation part

Explanation:

SELECT json_object('name'          VALUE first_name || ' ' || last_name,

                  'hasCommission' VALUE

                    CASE WHEN commission_pct IS NULL THEN 'false' ELSE 'true'

                    END FORMAT JSON)

 FROM employees WHERE first_name LIKE 'W%';

JSON_OBJECT('NAME'ISFIRST_NAME||''||LAST_NAME,'

-----------------------------------------------

{"name":"William Gietz","hasCommission":false}

{"name":"William Smith","hasCommission":true}

{"name":"Winston Taylor","hasCommission":false}

import csv

filename = "aapl.csv"

fields = []

rows = []

with open(filename, 'r') as csvfile:

 

csvreader = csv.reader(csvfile)

 fields = next(csvreader)

       for row in csvreader:

 rows.append(row)

          print("Total no. of rows: %d"%(csvreader.line_num))

print('Field names are:' + ', '.join(field for field in fields))

print('\nFirst 5 rows are:\n')

for row in rows[:5]:

         for col in row:

 print("%10s"%col),

print('\n')

Similar questions