airbnb csv parser
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2021-06-28Added By Anonymous
Source: Link
1
2# There are two things to focus on. The first (and most importantly)
3
4# is correctly parsing the CSV format. The second is writing
5
6# clean code that another engineer would enjoy using.
7
8#
9
10# You may assume that the CSV file is correctly formatted.
11
12#
13
14# An ideal parse will look like this:
15
16# [['John', 'Smith', 'john.smith@gmail.com', 'Los Angeles', '1'],
17
18# ['Jane', 'Roberts', 'janer@msn.com', 'San Francisco, CA', '0'],
19
20# ['Alexandra "Alex"', 'Menendez', 'alex.menendez@gmail.com', 'Miami', '1'],
21
22# ['1','2','','4','5']]
23
24
25
26csv_lines = [
27
28 'John,Smith,john.smith@gmail.com,Los Angeles,10',
29
30 'Jane,Roberts,janer@msn.com,"San Francisco, CA",0',
31
32 '"Alexandra ""Alex""",Menendez,alex.menendez@gmail.com,Miami,1',
33
34 '1,2,,4,"5"'
35
36]