Skip to content

Instantly share code, notes, and snippets.

@Ke-
Created April 6, 2019 00:20
Show Gist options
  • Select an option

  • Save Ke-/06fd5279b50dfbb9cd59cf6bf94e65ee to your computer and use it in GitHub Desktop.

Select an option

Save Ke-/06fd5279b50dfbb9cd59cf6bf94e65ee to your computer and use it in GitHub Desktop.
Tab delimited data to array of Lasso maps.
define tab_to_maps(p::staticarray) => tab_to_map(: #p )
define tab_to_maps(p::string, ...) => {
local(
delimiter = '\t',
lines = params->size > 1 ? params | #p->split('\n'),
cols = #lines->first->split(#delimiter),
out = array
)
with line in #lines
skip 1
where #line
let row = #line->split(#delimiter)
let m = map
do protect => {
handle_error => {
debug(error_msg = #row)
}
local(i) = 1
#cols->foreach => {
#m->insert(
#1 = #row->get(#i++)
)
}
#out->insert(#m)
}
return #out
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment