Note
This script requires this packages:
pip3 install pandas tabulate
- Change
foo.csv
to your CSV file name.
import pandas as pd
from tabulate import tabulate
def csv_to_markdown_table(filename):
data = pd.read_csv(filename)
resource_types = data['Resource Type'].unique()
for resource_type in resource_types:
filtered_data = data[data['Resource Type'] == resource_type]
markdown_table = tabulate(filtered_data, headers="keys", tablefmt="pipe", showindex=False)
output_filename = f"{resource_type.replace(' ', '_')}.md"
with open(output_filename, "w") as f:
f.write(markdown_table)
csv_to_markdown_table("foo.csv")