Commit b84536cc authored by sainath taidalwar's avatar sainath taidalwar

Delete records.py

parent b62d99f8
Pipeline #21817 failed
with open ('my.csv', 'r') as f:
for line in f:
line = line.strip()
row = line.split(',')
print(row)
from tabulate import tabulate
import csv
myrows=[]
records=[]
with open('my.csv','r') as f:
r = csv.DictReader(f)
for row in r:
records.append(row)
print(records)
from collections import OrderedDict
def select_cols(records, columns):
new_records = []
for record in records:
new_record = OrderedDict()
for c in columns:
new_record[c] = record[c]
new_records.append(new_record)
return new_records
select_cols(records,['Names','CGPA'])
def print_records_fancy(records):
xyz = list(records[0].keys())
recs = []
for record in records:
recs.append(list(record.values()))
print(tabulate(recs, headers=xyz))
student = select_cols(records, ['Names', 'CGPA'])
print_records_fancy(student)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment