Azure DevOps Wiki written in Markdown the Pythonic way
Azure DevOps > wiki is able to interpret HTML an Markdown. But what if you want to import tables into the Wiki? Please let me know, if there’s a better way, in the meantime this is my approach.

To make the header of a wiki looking pretty, HTML with all it’s styling options is a good choice.
For the rest, the code becomes hard to read and Markdown would be much easier to maintain. But for tables, writing Markdown manually is not an option.
Python offers an easy way to convert CSV files into markdown.
Python
import pandas as pd
import os
os.getcwd() # in case you don't know the path to your input file or where you'll write the output file (here line 6 and line 13)
df = pd.read_csv('../???/input_file.csv', encoding="utf-8", sep=",") # read
df = df.fillna('') # clear all empty cells 'Nan'
# now convert the csv to markdown
df_to_markdown = df.to_markdown(index=False)
# open a text file
text_file = open('../???/output_file.txt', "w")
#write string to file
text_file.write(df_to_markdown)
#close file
text_file.close()That’s it. Style your DevOps wiki header with html and do the rest with Markdown. If you want to use tables in your wiki, just go Pythonic 😉





Schreibe einen Kommentar