sbac
sbac

Reputation: 2081

How to convert a .csv file into a markdown outlined file?

My data is contained in the following csv file, which has the following format:

ind h1 h2  x
1   a  aa  k 
2   a  ab  m 
3   b  ba  n 
4   b  bb  p 

And I want to convert this into this markdown file:

# a
## aa
k
## ab
m
# b
## ba
n
## bb
p

Upvotes: 0

Views: 77

Answers (1)

runr
runr

Reputation: 1146

Assume dt is the dataframe from csv,

library(glue)
library(magrittr)
with(dt,{
  '\n#{h1}\n##{h2}\n{x}\n' %>% glue 
}) %>% writeLines(., con = 'out.md')

Upvotes: 2

Related Questions