This was my 1st round of my Google interview of Machine coding. The interviewer was Indian asked me real time relevant problem.
Problem Statement : The application we are building allows users to upload a CSV containing data that we need to parse into a data structure that we can then use to
(for example)
put that data into our database.
A sample CSV file might look like (note that this is one input string):
product_id,product_name,stock_remaining
1,pixel5,55
2,pixelbook,31
3,nesthub,2
Write a function parseCSV(inputString) that can parse this CSV and return the parsed data in an appropriate data structure.
It is up to you what data structure you choose to return the data in.
FollowUp Question : If a given value in a CSV row has a comma inside, it will be quoted. For example, let's imagine a fourth row for our sample input:
4,"the, new, pixel!",5
How can we update our solution to correctly parse this row into its three values:
4
the, new, pixel!
5