Thank you so much guys I try to implement it! <3

Il giorno giovedì 29 settembre 2022 alle 18:53:29 UTC+2 mfhepp ha scritto:
As my last post might have been too brief to be actually helpful, here is a complete example:

1. Python Script
================

# csv2md.py
# Run with
# python csv2md.py > markdown_file.md

import csv

# Read from file and return dict with keys from first line in CSV
with open('data/performance_review.csv', newline='') as csvfile:
reader = csv.DictReader(csvfile)
# Convert to a list so that we can access it multiple times
reader = list(reader)

print("# Employee Assessment Report")
print()
print("This report contains assessments for the following staff members:")
print()
for row in reader:
print(f"- {row.get('name', '[Name missing]')}")
print()

for row in reader:
print(f"# Employee: {row.get('name', '[Name missing]')}")
print()
print(f"## Job Position: {row.get('position', 'N/A')}")
print()
print(f"{row.get('job_description', 'No detailed description available.')}")
print()
print(f"## Assessment")
print()
print(f"**Overall Performance:** {row.get('rating', 'N/A')} of 5")
print()
print(f"{row.get('review', 'No detailed review available.')}")

2. Example File data/performance_review.csv
===========================================

name, position, job_description, rating, review
Joe Miller, Developer, "Python back-end", 4, "Hard-working and diligent"
Paula Mayer, CIO, "Overall IT responsibility", 4, "Effective and motivating"

3. Output markdown_file.md
==========================

# Employee Assessment Report

This report contains assessments for the following staff members:

- Joe Miller
- Paula Mayer

# Employee: Joe Miller

## Job Position: N/A

No detailed description available.

## Assessment

**Overall Performance:** N/A of 5

No detailed review available.
# Employee: Paula Mayer

## Job Position: N/A

No detailed description available.

## Assessment

**Overall Performance:** N/A of 5

No detailed review available.

4. Rendering
============

You can then use any Pandoc workflow you like to convert that into PDF, MS Word, etc.

If the data is a bit more complex, I would parse into a Pandas DataFrame and process the data in there, like so

df = pd.read_csv('data/performance_review.csv')


Hope that helps!

Best wishes
Martin


Resources:
=========

- https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html
- https://docs.python.org/3/library/csv.html


-----------------------------------
martin hepp https://www.heppnetz.de
mfh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org











> On 28. Sep 2022, at 12:38, Thomas Chevrier <tch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> https://stackoverflow.com/questions/71224773/dynamically-set-r-markdown-title-output-filename-and-global-variables
>
> could this be of any help to what you are trying to achieve or am I misreading your issue? Apologies if so.
>
> On Wednesday, September 28, 2022 at 6:06:57 AM UTC+9 gianluc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
> Hi everyone,
>
> I try to create a Structured PDF (Title, headers, dates, and other stuff) starting from a CSV file which contain an header and responses. This CSV was generated by a Google Forms Questions and Answer, and starting from that one I want to create a simple formatted document.
>
> Anyone have some ideas on which characteristcs of pandoc can I use to obtain this results?
>
> As example, i share with you some screen of the desidered results
>
> CSV file:
>
> PDF (output) file
>
>
> Thank you so much for your help!
>
> --
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discus...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0df46ea0-a6a6-4abc-a6df-2e48fe895fb2n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/1a763402-668c-42e6-907a-761d04f6f0b9n%40googlegroups.com.