AI Native challenges by level

Level 2 · Applied · State and workflows

Parse quoted CSV

Handle embedded commas, newlines and escaped quotes.

Problem statement

Write function solution(text). Inputs and outputs are JSON values. Do not modify input arrays or objects. External libraries, network access, and asynchronous functions are not supported. text is valid CSV. Separator is comma; records use LF, CRLF or CR. A field may be fully double-quoted; inside it retain commas/newlines and unescape doubled quotes. Do not trim whitespace. A terminal record separator adds no phantom row. Empty text returns []; a blank record is ['']. Return arrays of field strings. Malformed CSV is outside the contract. Input limits: at most 50,000 items per input array and 1,000 characters per string. Numbers are finite; integers and accumulated integer results stay in the JavaScript safe-integer range. Other types and validity rules follow the statement above.

Example input and output

Example 1

Function arguments

[
  "a,b\n1,2"
]

Return value

[
  [
    "a",
    "b"
  ],
  [
    "1",
    "2"
  ]
]
Example 2

Function arguments

[
  "\"a,b\",\"x\"\"y\"\r\n3,4"
]

Return value

[
  [
    "a,b",
    "x\"y"
  ],
  [
    "3",
    "4"
  ]
]
Example 3

Function arguments

[
  "서울,\"공백\""
]

Return value

[
  [
    "서울",
    "공백"
  ]
]
Practice has no points, deadline or submission cap. Use AI and search freely. Sign in to run public examples, or verify locally.

69 / 20,000 characters

Add your test · optional

Enter a JSON argument array in text order. Your test runs alongside the three examples.

Save both files in one folder and run this command with Node.js. Read the checks field for individual example results.

node verify-csv-parser.mjs
문의하기

서비스명: 포트포올
문의는 운영자에게 이메일로 전송됩니다.

이메일과 문의 내용은 답변을 위해 운영자 및 메일 발송 서비스로 전송됩니다. 비밀번호·결제정보·민감한 개인정보는 입력하지 마세요.