public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Gianluca Carbone <gianlucarbone96-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Formatted PDF from CSV data
Date: Wed, 12 Oct 2022 03:11:30 -0700 (PDT)	[thread overview]
Message-ID: <1a763402-668c-42e6-907a-761d04f6f0b9n@googlegroups.com> (raw)
In-Reply-To: <51C50E26-9499-4EDB-8E59-82877AB3B2CF-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 4839 bytes --]

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...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.

[-- Attachment #1.2: Type: text/html, Size: 7819 bytes --]

      parent reply	other threads:[~2022-10-12 10:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27 21:06 Gianluca Carbone
     [not found] ` <7db8040f-dd62-416f-a3d7-a88c1e257d9en-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-09-28  0:59   ` Martin Hepp
2022-09-28 10:38   ` Thomas Chevrier
     [not found]     ` <0df46ea0-a6a6-4abc-a6df-2e48fe895fb2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-09-29 16:53       ` Martin Hepp
     [not found]         ` <51C50E26-9499-4EDB-8E59-82877AB3B2CF-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-10-12 10:11           ` Gianluca Carbone [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a763402-668c-42e6-907a-761d04f6f0b9n@googlegroups.com \
    --to=gianlucarbone96-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).