Create plain textfile in a specific format?

Hello,

I’ve got a csv-file (actually I got loads) and I want to create a kind of markdown file from each csv-file. It’s basically a plain textfile but it needs to be in a specific format to be useful for another program (HUGO) that uses it to build a website on these files.

My CSV-content is structured like this (first row is column names)
"show_id",“type”,"title"
60000861,“Movie”,“American Psycho”

This is the structure that I need in my textfile .

show_id: 60000861
type:Movie
title:American Psycho

I guess this could be achieved with a JavaSnippet or a PythonScript within Knime but I was hoping there would be a node that would let me dictate a format for an output file but so far I haven’t found anything. I’ve looked at CSV Writer and it can write text-files but not in the format I need and it doesn’t let me decide the file suffix, which need to be .md.

Any help or pointers greatly appreciated!

Thanks!

Hi,
you can create the format using the String Manipulation node using the following expression:

join("show_id: ", $show_id$, "\r\ntype: ", $type$, "\r\ntitle: ", $title$)

Then filter out all other columns and write the table using the CSV Writer. You can simply change the file extension in the text box with the file path after you have selected a path using the Browse-button. In the tab “Quotes” you should also set to never use quotes. The result should match your desired output format.
Kind regards
Alexander

2 Likes

Thanks a million! Very clever and straightforward solution. That was exactly what I needed - much appreciated!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.