Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Ajuanca/ExtraTabular
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
p = {} -- Join two tables. -- Number index are added over the first table. -- Other type of keys are added "as they are". function p.join_tables(_table1, _table2) for k, arg in pairs(_table2) do if not tonumber(k) then _table1[k] = arg else table.insert(_table1, arg) end end return _table1 end -- Converts table data type to String. -- Keys should be int numbers. -- Values are concatenated with ", " function p.table2string(_table) original_table = _table wrapped = "" for i=1, #original_table do wrapped = wrapped .. original_table[i] .. ", " end return wrapped:sub(0, -3) end function p.get_rows(frame) return p._get_rows(frame.args) end function p.string2table(_string) -- Should work for nested values. _string = "test,[home,cheese],[restaurant,pc]" ltable = {} for value in _string:gmatch("%[(%[^%[%a+%])%]") do if string:find(value, "[^%[]") then ntable = {} for column in value:gmatch("[^,]+") do table.insert(ntable, column) end table.insert(ltable, ntable) else end end return mw.logObject(ltable) end function p._get_rows(args) local page = args.src or args[1] local data = mw.ext.data.get(page) local columns_input = args.columns or args[2] local columns_table = p.string2table(column_input) -- local column_names = args.column_names or args[2] -- local column_groups = args.column_groups or args[3] -- Also optional title for rows should be included. local date_name = args.date_name or args[3] rows = {} rows.titles = {} rows.values = {} end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Ajuanca/ExtraTabular/doc
(
edit
)