python - How do I delete a dict item that is a 'NoneType'? -


i'm making program takes salesforce reports, iteraters through them , displays them in flask app.

from flask import flask flask import render_template import csv import collections app = flask(__name__) # odict_keys(['edit', 'activity id', 'assigned', 'subject', 'last modified date', 'date', 'priority' # , 'status', 'company / account', 'created by', 'activity type', 'comments'])   @app.route('/') def hello_world():      reports = {}     open('./reports/report040717.csv', newline='') csvfile:         reader = csv.dictreader(csvfile, delimiter=',', quotechar='"')         row in reader:              temp = {row['activity id']: {'subject': row['subject'], 'due_date': row['date'], 'last_modified': row['last modified date'], 'status': row['status'],                                          'company': row['company / account'], 'type': row['activity type'], 'comments': row['comments']}}             reports.update(temp)      reports = collections.ordereddict(reversed(list(reports.items())))      k, v in reports.items():         print(k, v)      return render_template('home.html', reports=reports) if __name__ == '__main__':     app.run() 

i'm storing of rows read dictionary, push dictionary dictionary id key.

the problem keep getting empty dictionary , can't figure out how delete it.
how showing when im printing k ,v values before calling render

none {'subject': none, 'due_date': none, 'last_modified': none, 'status': none, 'company': none, 'type': none, 'comments': none}   

and how of other shows

00tf000003ti9ie {'subject': 'some text', 'due_date': '4/18/2017', 'last_modified': '8/23/2016', 'status': 'not started', 'company': 'some text', 'type': 'some text', 'comments': 'some text'}   

any suggestions on how delete none entry in report dict?

i imagine reading in empty rows csv file. can following empty rows aren't loaded dictionary @ all:

if row['activity id'] , row['subject']:     # row added if values above aren't none     temp = {row['activity id']: {'subject': row['subject'], 'due_date': row['date'], 'last_modified': row['last modified date'], 'status': row['status'],                                      'company': row['company / account'], 'type': row['activity type'], 'comments': row['comments']}}     reports.update(temp) 

Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -