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.
CSV.read(file) returns array of arrays (rows)
First row is headers: data[0], remaining rows: data[1..]
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(' | ')
File.write(filename, content) writes string to file
generate_markdown_table('data.csv', 'output.md')
Markdown table generated: 4 rows, 4 columns
generate_markdown_table('data.csv', 'output.md')
Markdown table generated: 3 rows, 3 columns
generate_markdown_table('data.csv', 'output.md')
Markdown table generated: 3 rows, 4 columns
Console output will appear here...
Are you sure?
You're making great progress