I have completed all the previous lectures but I am not able to understand how to make a CSV file. I hav extracted the jokes from the url,converted them to python dictionary and need guidance in the further steps.
I don't know know how to extract the useful data and form a CSV file in Chuck Norris Jokes problem
hey @18127 ,
we are here to help you if you get stuck at any point , but before i help you .
I would suggest you to first understand search about on how to convert a dictionary to a csv file.
I can provide you directly the code , but that will not help learn something.
for a bit help , search about pandas module and specifically its .from_dict() function.
if still you get stuck somewhere , just ask me . I will help you at that point.
Thank You and Happy Learning .
I will read that, thank you.
However, i just wanted to know if it can be done by any method that you have already taught in previous lectures, i.e. just like we did html parsing or something.
not exactly , but similar to it, creating csv files will be taught in either pandas series or python basics series.
It has been 2 days since I submitted my CSV file, can you tell me when will I get the result
you should have got your result at the same time after uploading it.
There might be some problem .
Do one thing share me your csv file , i will let you know what you score is.
How can I share the file with you ?
Can I send you the code ?
you can either upload it on github or drive and share me its link.
hey @18127,
Nice work dude.
You have got 100% accuracy .
The actual problem is the way are creating your file. If we read your file with csv module at each alternate line it contains an empty space, which our script running at the server can’t understand and hence wasn’t able to show you the results.
You may correct that and try again .
Thank You .
This is the link of my code, can you please let me know where is the error and how can I correct it
Kindly let me have a look once. Will tell you after that.
Thank You
just replace your last code snippet with
f_names=['ID', 'Joke']
csv_file = 'jokes.csv'
with open(csv_file,'w') as f:
f.write(",".join(f_names)+"\n")
# writer.writerow(f_names)
for i in dic_data:
id = i['id']
joke = i['joke']
if joke.find(",") != -1:
joke = '"{}"'.format(joke)
f.write(",".join([str(id),joke])+"\n")
it will do your task,