Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!

Megha Raj

+ Follow
since Dec 26, 2018
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Megha Raj

I have written a code to convert csv file to nested json format. I have multiple columns to be nested hence assigning separately for each column. The problem is I'm getting 2 fields for the same column in the json output.
I'm getting 2 entries for the fields I have assigned using row[''].
1.Is there any other way to get rid of this? I want only one entry for a particular field in each record.  
2. Also how can I convert the keys to lower case after reading from csv.DictReader(). In my csv file all the columns are in upper case and hence I'm using the same to assign. But I want to convert all of them to lower case.

Below is the output getting:

I'm expecting output to be like below:

4 weeks ago
Thanks for your time. I got the solution.
I'm trying to display the result if a user types a name in the url i.e localhost:5000/user/username. i want to display the custom error if username is either empty or any number. For that I have written the code as below using python and flask and I'm getting proper result if username is specified but not getting the custom error while giving number instead getting internal server error. Error handler function is not getting executed. I think it's not getting any exception even if the username is empty. what changes I need to make in order to display custom error page.

from flask import Flask
app = Flask(__name__)

def hello(username):
   if username == username:
       return 'Hello, {}'.format(username)

def name_error():
   return 'enter username and then try'

if __name__ == '__main__':
#     app.debug = True '', port = 5000)