Skip to content

Instantly share code, notes, and snippets.

@FrigoEU
Last active August 30, 2018 11:11
Show Gist options
  • Save FrigoEU/efa84e7863d40783684f351406419e96 to your computer and use it in GitHub Desktop.
Save FrigoEU/efa84e7863d40783684f351406419e96 to your computer and use it in GitHub Desktop.
Parsing CSV
Parsing CSV
New Line*
EOF -> Done
Not EOF -> Reading Field
Reading Field
EOF -> Not Quoted
First character is quote -> Quoted
First character is not quote -> Not Quoted
Quoted
Read till next quote and use as value -> After Quoted
After Quoted
Drop until next comma or enter or EOF but drop -> After Field
Not Quoted
Read till next comma or enter or EOF and keep as value -> After Field
After Field
First char is comma -> Reading Field
First char is enter -> Process Line
First char is EOF -> Process Line
First char is something else -> Parse Error
Process Line
We have zero fields read -> New Line
We have one field read and the field is nothing but spaces -> New Line
We have the exact amount of fields so we add to list -> New Line
We dont have the exact amount of fields -> Parse Error
Parse Error
Done
function render(model){
let current_state_name = model.active_states[0].name;
return $("h1",
{style: {color: "darkBlue"}},
`The current state is: ${current_state_name}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment