Skip to content

Instantly share code, notes, and snippets.

@elct9620
Created May 25, 2017 09:21
Show Gist options
  • Save elct9620/c70f3faa7f0e7505f6ebba84fefd0d59 to your computer and use it in GitHub Desktop.
Save elct9620/c70f3faa7f0e7505f6ebba84fefd0d59 to your computer and use it in GitHub Desktop.
function RawToBook(raw) {
var columns = raw.split(',');
return {
IBSN: columns[0],
Title: columns[1],
Author: columns[2],
Press: columns[3],
Class: columns[4],
Description: columns[5],
};
}
function ParseStringToBooks(raw) {
if(raw.length == 0) {
return;
}
var rows = raw.split(';');
return rows.map(RowToBook);
}
var books = ParseStringToBooks(input);
// books[0].IBSN => 123456
// books[1].Title => "XXXXX"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment