Documentation is critical in software development, and markdown is the universal format for READMEs, wikis, and documentation sites. This drill teaches you to read CSV data and transform it into properly formatted markdown tables with alignment, padding, and separators. You'll learn markdown table syntax, dynamic column width calculation, string alignment techniques, and text formatting—skills essential for generating documentation, reports, and developer tools. Note: This drill parses CSV manually using string methods rather than Ruby's CSV library.
Parse CSV manually: line.split(',')
First row is headers, remaining rows are data
Calculate max width: array.map(&:length).max
Use map.with_index to iterate with column index
string.ljust(width) pads right, string.rjust(width) pads left
Check if numeric: string.match?(/^\d+\.?\d*$/)
Join array with separator: array.join(' | ')
generate_markdown_table('data.csv')
Markdown table generated: 4 rows, 4 columns
md = generate_markdown_table('data.csv')
puts md.lines.first
Markdown table generated: 4 rows, 4 columns | Name | Department | Salary | Years |
md = generate_markdown_table('data.csv')
puts md.lines[1]
Markdown table generated: 4 rows, 4 columns | ----- | ----------- | ------ | ----- |
Console output will appear here...
Are you sure?
You're making great progress
Become a Ruby Pro
1,600+ problems to master every concept