read_csv with double quotes
As you have mentioned in this lesson, that a separate section has been dedicated to resolve the issue of "importing data as csv with double quotes" after a separator is assigned as in
my_csv_data = pd.read_csv(filename,sep='\,',engine='python'). The double quotes issue is not addressed in any of the lessons. Can you please provide this solution?
Hi Dhaivat!
Thanks for reaching out.
Sorry for the inconvenience. I suppose the idea is to refer to the comma symbol ,
. One way is to refer to it with the help of the backslash character(as you've stated in the question - '\,'
). Alternatively, you can avoid the use of the backslash character and use double quotes with the comma symbol directly: ","
.
Hope this helps but please feel free to get back to us should you need further assistance. Thank you.
Best,
Martin
Thanks, Martin for your informative reply.
However, my question refers to the issue shown in the below screenshot - how can we deal with the double quotes appearing at the 2 ends of each string on each separate row?:
Hi Dhaivat!
Thanks for your reply.
Your question is excellent and extremely relevant. We have not dealt through it throughout this course because the tools Python provides to us to swiftly remove the double quotes from strings regard a dew different topics. We cover all of them in our Intermediate Python Programming course (https://learn.365datascience.com/courses/preview/intermediate-python-programming/). These topics regard tools used for working with text data (particularly the .replace()
method) as well as using lambda functions. I invite you to cover that course as well and try importing the dataset in a manner that you will like (you will see that the tools provided in that course will open a lot of doors for you to import your data with even higher precision).
Hope this helps.
Kind regards,
Martin
Thanks, Martin. I will surely explore the suggested course.
Regards, Dhaivat
You are very welcome and thank you very much!
Good luck and please feel free to post another question should you encounter any difficulties. Thank you.
Best,
Martin