From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31527 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gianluca Carbone Newsgroups: gmane.text.pandoc Subject: Re: Formatted PDF from CSV data Date: Wed, 12 Oct 2022 03:11:30 -0700 (PDT) Message-ID: <1a763402-668c-42e6-907a-761d04f6f0b9n@googlegroups.com> References: <7db8040f-dd62-416f-a3d7-a88c1e257d9en@googlegroups.com> <0df46ea0-a6a6-4abc-a6df-2e48fe895fb2n@googlegroups.com> <51C50E26-9499-4EDB-8E59-82877AB3B2CF@gmail.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_816_1949440225.1665569490489" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14852"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDYLVBUDZEBBBVFFTKNAMGQEVJSJOJY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Oct 12 12:11:35 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f58.google.com ([209.85.161.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oiYi7-0003ff-80 for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 12 Oct 2022 12:11:35 +0200 Original-Received: by mail-oo1-f58.google.com with SMTP id n5-20020a4a3445000000b004728fe7a331sf9195134oof.23 for ; Wed, 12 Oct 2022 03:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :sender:from:to:cc:subject:date:message-id:reply-to; bh=njnBoQSFOOYzUxZUaYYN83HTBAgBJRZPsbEuJEqhMJ8=; b=PtvSChQR7rvrlc1t3uxvSbPKS9shWJir/pq1/YRsI5RHBulzdHt+gESIifPfd1JxGu yzJM94SlzNQSU2AfKHujb5GSdYyiijxZ4Kjw4GqH9i3+Y8irzExyIOLTjh3L3iy4UDNt OGU7nJOrlG0LQtVMltWnPSB+kPOC5VgY4r4uhKPQlvr9Bg0EHDZuifAIS/v+ONQZD3u9 8RPuaqAMXl19jL8hpBQxgeYxA0JGh2HaEh1gMsPtj5gShUvtlniGs1OPLHOELUPPN5n8 uo7JGvdK2xyOXnwxdmH9B2PBfHDI19p9PlSHGtXZ7gNegsiG1VNZMwOOqhcG2IzjGxkx YgGw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=njnBoQSFOOYzUxZUaYYN83HTBAgBJRZPsbEuJEqhMJ8=; b=AY6Ea+sVnm2wd5tyb26IP/wLPnz9Gw61Gzx0mJpfDy+FlGbjjVct3N7ITXI4f/X5D3 0CwybDeYAgnQNxDRxa/YWfJN+v5xeg8AauURiGxWbK3zUodDMSuR8g/b33FGtFKFjj/Q uq+ddaKLfzaB1dZFBiILJSqcdnO3gOxCQ7egQaZLey66fECjiILv9aMGIyfidw6FKsoK azo8IKzHt+rBqbXGS2AbEJK87Danl/qN475f2M4Jcm/JuaU9KNKdl6v9sF1OKibPsIVA qor8y8mSDSGQvGbti962ia6x1CbomuT/6flo3++dUYDiBq8/0COzLRql2oV/oDAOlUKu gK+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-gm-message-state:sender:from:to:cc :subject:date:message-id:reply-to; bh=njnBoQSFOOYzUxZUaYYN83HTBAgBJRZPsbEuJEqhMJ8=; b=0XTkr8G/YF4GY0xNLUw1ur+rTvRQBkk6+22WhESiJscdQsFdXuwg+5YVzt4khX1iL2 mpHNwcFur75fnBcwznEQBj7yFoPzoY7/RKy+cojY6KwqyImwsvCk2n/6wWGFE3ir14Ub Bk/CoQmupq31814NsLPTTaKUMPec3QqRDwjESSGI3o+WX8Z+FDyxzIC0+vnswEf5okmx NQQvCCnwcbkiII41ReG4xXR8y1MhvUYkswN+Z5vNITKWMyDWZaDQTPFVtzVSVDcFe1Qd MH8TzsEOog3CnPExff0VTvbLIaciTX1i3rCMXFeJNPc5aEHPXxfjIFECV5c8rvWkMje9 nwQA== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ACrzQf24vcHUm9gy9OLzsxphXOH3isW5fmVlG5gQbVNiizJqvV39k7ls GsU0NxXJ/S/THU1E3P+W+5U= X-Google-Smtp-Source: AMsMyM4E96kfv8jttQyI2ET8GGbc+Q51Hdwn9T/Gma2GcIoMLAZ7MaCPFV2Qrs1zGiVALa5jIi8grA== X-Received: by 2002:a05:6870:e0c9:b0:132:2090:20f7 with SMTP id a9-20020a056870e0c900b00132209020f7mr1899938oab.277.1665569494043; Wed, 12 Oct 2022 03:11:34 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:7735:b0:132:4cb:dd6 with SMTP id dw53-20020a056870773500b0013204cb0dd6ls5216656oab.2.-pod-prod-gmail; Wed, 12 Oct 2022 03:11:31 -0700 (PDT) X-Received: by 2002:a05:6870:d5a1:b0:133:10c4:b9b4 with SMTP id u33-20020a056870d5a100b0013310c4b9b4mr1975228oao.166.1665569491460; Wed, 12 Oct 2022 03:11:31 -0700 (PDT) In-Reply-To: <51C50E26-9499-4EDB-8E59-82877AB3B2CF-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> X-Original-Sender: gianlucarbone96-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:31527 Archived-At: ------=_Part_816_1949440225.1665569490489 Content-Type: multipart/alternative; boundary="----=_Part_817_211302774.1665569490489" ------=_Part_817_211302774.1665569490489 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you so much guys I try to implement it! <3 Il giorno gioved=C3=AC 29 settembre 2022 alle 18:53:29 UTC+2 mfhepp ha scri= tto: > As my last post might have been too brief to be actually helpful, here is= =20 > a complete example: > > 1. Python Script > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > # 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=3D'') as csvfile: > reader =3D csv.DictReader(csvfile) > # Convert to a list so that we can access it multiple times > reader =3D 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()=20 > print(f"{row.get('job_description', 'No detailed description=20 > available.')}") > print()=20 > print(f"## Assessment") > print()=20 > print(f"**Overall Performance:** {row.get('rating', 'N/A')} of 5") > print()=20 > print(f"{row.get('review', 'No detailed review available.')}") > > 2. Example File data/performance_review.csv > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > 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=20 > motivating" > > 3. Output markdown_file.md > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D > > # 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 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > You can then use any Pandoc workflow you like to convert that into PDF, M= S=20 > Word, etc. > > If the data is a bit more complex, I would parse into a Pandas DataFrame= =20 > and process the data in there, like so > > df =3D pd.read_csv('data/performance_review.csv') > > > Hope that helps! > > Best wishes > Martin > > > Resources: > =3D=3D=3D=3D=3D=3D=3D=3D=3D > > - 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 wrote: > >=20 > >=20 > https://stackoverflow.com/questions/71224773/dynamically-set-r-markdown-t= itle-output-filename-and-global-variables=20 > >=20 > > could this be of any help to what you are trying to achieve or am I=20 > misreading your issue? Apologies if so. > >=20 > > On Wednesday, September 28, 2022 at 6:06:57 AM UTC+9=20 > gianluc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > Hi everyone,=20 > >=20 > > I try to create a Structured PDF (Title, headers, dates, and other=20 > stuff) starting from a CSV file which contain an header and responses. Th= is=20 > CSV was generated by a Google Forms Questions and Answer, and starting fr= om=20 > that one I want to create a simple formatted document. > >=20 > > Anyone have some ideas on which characteristcs of pandoc can I use to= =20 > obtain this results? > >=20 > > As example, i share with you some screen of the desidered results > >=20 > > CSV file: > >=20 > > PDF (output) file > >=20 > >=20 > > Thank you so much for your help! > >=20 > > --=20 > > You received this message because you are subscribed to the Google=20 > Groups "pandoc-discuss" group. > > To unsubscribe from this group and stop receiving emails from it, send= =20 > an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/0df46ea0-a6a6-4abc-a6df-= 2e48fe895fb2n%40googlegroups.com > . > > --=20 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 e= mail 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. ------=_Part_817_211302774.1665569490489 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you so much guys I try to implement it! <3

Il giorno gioved= =C3=AC 29 settembre 2022 alle 18:53:29 UTC+2 mfhepp ha scritto:
<= blockquote class=3D"gmail_quote" style=3D"margin: 0 0 0 0.8ex; border-left:= 1px solid rgb(204, 204, 204); padding-left: 1ex;">As my last post might ha= ve been too brief to be actually helpful, here is a complete example:

1. Python Script
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

# 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=3D'') = as csvfile:
reader =3D csv.DictReader(csvfile)
# Convert to a list so that we can access it multiple times
reader =3D list(reader)

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

for row in reader:
print(f"# Employee: {row.get('name', '[Name missin= g]')}")
print()
print(f"## Job Position: {row.get('position', 'N/A= ')}")
print() =20
print(f"{row.get('job_description', 'No detailed d= escription available.')}")
print() =20
print(f"## Assessment")
print() =20
print(f"**Overall Performance:** {row.get('rating', &#= 39;N/A')} of 5")
print() =20
print(f"{row.get('review', 'No detailed review ava= ilable.')}")

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

name, position, job_description, rating, review
Joe Miller, Developer, "Python back-end", 4, "Hard-worki= ng and diligent"
Paula Mayer, CIO, "Overall IT responsibility", 4, "Effec= tive and motivating"

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

# 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

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 DataFram= e and process the data in there, like so

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


Hope that helps!

Best wishes
Martin


Resources:
=3D=3D=3D=3D=3D=3D=3D=3D=3D

- https://pandas.pydata.org/docs/refere= nce/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:
>=20
> https://st= ackoverflow.com/questions/71224773/dynamically-set-r-markdown-title-output-= filename-and-global-variables=20
>=20
> could this be of any help to what you are trying to achieve or am = I misreading your issue? Apologies if so.
>=20
> On Wednesday, September 28, 2022 at 6:06:57 AM UTC+9 gianluc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
> Hi everyone,=20
>=20
> I try to create a Structured PDF (Title, headers, dates, and other= stuff) starting from a CSV file which contain an header and responses. Thi= s CSV was generated by a Google Forms Questions and Answer, and starting fr= om that one I want to create a simple formatted document.
>=20
> Anyone have some ideas on which characteristcs of pandoc can I use= to obtain this results?
>=20
> As example, i share with you some screen of the desidered results
>=20
> CSV file:
>=20
> PDF (output) file
>=20
>=20
> Thank you so much for your help!
>=20
> --=20
> 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-a= 6a6-4abc-a6df-2e48fe895fb2n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-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.
------=_Part_817_211302774.1665569490489-- ------=_Part_816_1949440225.1665569490489--