Populate information from a csv file into a LaTeX document (specifically into the fields/arguments of...












7















I have some personal information stored in a plain CSV file personal_info.csv in the following format:



personal_info.csv



83 Fancy Avenue,Nowheresville,Gotham City 24061
123 456 7890
someone@xyz.com


I need to populate the relevant fields of the below main.tex (non-working/mockup) using class moderncv with this personal information as shown below.



Mock-up (non-working concept) of main.tex



documentclass[11pt,a4paper,sans]{moderncv}
moderncvstyle{classic}

firstname{John}
familyname{Doe}

%% NOT WORKING MOCKUP! (Relevant content to be read from csv file `personal_info.tex`)
address{firstfieldofline1}{secondfieldofline1}{thirdfieldofline2}
phone[mobile]{firstfieldofline2}
email{firstfieldofline3}

begin{document}
makecvtitle
end{document}


to produce the desired output main.pdf (compiled with pdflatex).



desired output with populated fields from csv file



How can this be achieved?










share|improve this question

























  • May I ask why you want to do that? You need such personal only one time in your cv, I think it would be better to include them directly. Did you already tried something? Can you show us that code?

    – Kurt
    8 hours ago











  • @Kurt I wish to open-source my CV in github (because my friends asked for it), but of course, don't want the whole world to know where I live. So, I shall be encrypting this csv file with gpg and committing to the repo.

    – Krishna
    8 hours ago








  • 2





    Why so complicated? use a file mydata.tex, define there dummy infos for the github and call it in your cv. For personal use keep a copy with real informations. No needs to encrypt or using complicated tools causing perhaps unwanted errors ... I'm not sure -- not tested -- that moderncv cooperates wirh datatool etc.

    – Kurt
    8 hours ago
















7















I have some personal information stored in a plain CSV file personal_info.csv in the following format:



personal_info.csv



83 Fancy Avenue,Nowheresville,Gotham City 24061
123 456 7890
someone@xyz.com


I need to populate the relevant fields of the below main.tex (non-working/mockup) using class moderncv with this personal information as shown below.



Mock-up (non-working concept) of main.tex



documentclass[11pt,a4paper,sans]{moderncv}
moderncvstyle{classic}

firstname{John}
familyname{Doe}

%% NOT WORKING MOCKUP! (Relevant content to be read from csv file `personal_info.tex`)
address{firstfieldofline1}{secondfieldofline1}{thirdfieldofline2}
phone[mobile]{firstfieldofline2}
email{firstfieldofline3}

begin{document}
makecvtitle
end{document}


to produce the desired output main.pdf (compiled with pdflatex).



desired output with populated fields from csv file



How can this be achieved?










share|improve this question

























  • May I ask why you want to do that? You need such personal only one time in your cv, I think it would be better to include them directly. Did you already tried something? Can you show us that code?

    – Kurt
    8 hours ago











  • @Kurt I wish to open-source my CV in github (because my friends asked for it), but of course, don't want the whole world to know where I live. So, I shall be encrypting this csv file with gpg and committing to the repo.

    – Krishna
    8 hours ago








  • 2





    Why so complicated? use a file mydata.tex, define there dummy infos for the github and call it in your cv. For personal use keep a copy with real informations. No needs to encrypt or using complicated tools causing perhaps unwanted errors ... I'm not sure -- not tested -- that moderncv cooperates wirh datatool etc.

    – Kurt
    8 hours ago














7












7








7


1






I have some personal information stored in a plain CSV file personal_info.csv in the following format:



personal_info.csv



83 Fancy Avenue,Nowheresville,Gotham City 24061
123 456 7890
someone@xyz.com


I need to populate the relevant fields of the below main.tex (non-working/mockup) using class moderncv with this personal information as shown below.



Mock-up (non-working concept) of main.tex



documentclass[11pt,a4paper,sans]{moderncv}
moderncvstyle{classic}

firstname{John}
familyname{Doe}

%% NOT WORKING MOCKUP! (Relevant content to be read from csv file `personal_info.tex`)
address{firstfieldofline1}{secondfieldofline1}{thirdfieldofline2}
phone[mobile]{firstfieldofline2}
email{firstfieldofline3}

begin{document}
makecvtitle
end{document}


to produce the desired output main.pdf (compiled with pdflatex).



desired output with populated fields from csv file



How can this be achieved?










share|improve this question
















I have some personal information stored in a plain CSV file personal_info.csv in the following format:



personal_info.csv



83 Fancy Avenue,Nowheresville,Gotham City 24061
123 456 7890
someone@xyz.com


I need to populate the relevant fields of the below main.tex (non-working/mockup) using class moderncv with this personal information as shown below.



Mock-up (non-working concept) of main.tex



documentclass[11pt,a4paper,sans]{moderncv}
moderncvstyle{classic}

firstname{John}
familyname{Doe}

%% NOT WORKING MOCKUP! (Relevant content to be read from csv file `personal_info.tex`)
address{firstfieldofline1}{secondfieldofline1}{thirdfieldofline2}
phone[mobile]{firstfieldofline2}
email{firstfieldofline3}

begin{document}
makecvtitle
end{document}


to produce the desired output main.pdf (compiled with pdflatex).



desired output with populated fields from csv file



How can this be achieved?







moderncv external-files datatool csvsimple metadata






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 7 hours ago









Kurt

37.5k847162




37.5k847162










asked 8 hours ago









KrishnaKrishna

1,062619




1,062619













  • May I ask why you want to do that? You need such personal only one time in your cv, I think it would be better to include them directly. Did you already tried something? Can you show us that code?

    – Kurt
    8 hours ago











  • @Kurt I wish to open-source my CV in github (because my friends asked for it), but of course, don't want the whole world to know where I live. So, I shall be encrypting this csv file with gpg and committing to the repo.

    – Krishna
    8 hours ago








  • 2





    Why so complicated? use a file mydata.tex, define there dummy infos for the github and call it in your cv. For personal use keep a copy with real informations. No needs to encrypt or using complicated tools causing perhaps unwanted errors ... I'm not sure -- not tested -- that moderncv cooperates wirh datatool etc.

    – Kurt
    8 hours ago



















  • May I ask why you want to do that? You need such personal only one time in your cv, I think it would be better to include them directly. Did you already tried something? Can you show us that code?

    – Kurt
    8 hours ago











  • @Kurt I wish to open-source my CV in github (because my friends asked for it), but of course, don't want the whole world to know where I live. So, I shall be encrypting this csv file with gpg and committing to the repo.

    – Krishna
    8 hours ago








  • 2





    Why so complicated? use a file mydata.tex, define there dummy infos for the github and call it in your cv. For personal use keep a copy with real informations. No needs to encrypt or using complicated tools causing perhaps unwanted errors ... I'm not sure -- not tested -- that moderncv cooperates wirh datatool etc.

    – Kurt
    8 hours ago

















May I ask why you want to do that? You need such personal only one time in your cv, I think it would be better to include them directly. Did you already tried something? Can you show us that code?

– Kurt
8 hours ago





May I ask why you want to do that? You need such personal only one time in your cv, I think it would be better to include them directly. Did you already tried something? Can you show us that code?

– Kurt
8 hours ago













@Kurt I wish to open-source my CV in github (because my friends asked for it), but of course, don't want the whole world to know where I live. So, I shall be encrypting this csv file with gpg and committing to the repo.

– Krishna
8 hours ago







@Kurt I wish to open-source my CV in github (because my friends asked for it), but of course, don't want the whole world to know where I live. So, I shall be encrypting this csv file with gpg and committing to the repo.

– Krishna
8 hours ago






2




2





Why so complicated? use a file mydata.tex, define there dummy infos for the github and call it in your cv. For personal use keep a copy with real informations. No needs to encrypt or using complicated tools causing perhaps unwanted errors ... I'm not sure -- not tested -- that moderncv cooperates wirh datatool etc.

– Kurt
8 hours ago





Why so complicated? use a file mydata.tex, define there dummy infos for the github and call it in your cv. For personal use keep a copy with real informations. No needs to encrypt or using complicated tools causing perhaps unwanted errors ... I'm not sure -- not tested -- that moderncv cooperates wirh datatool etc.

– Kurt
8 hours ago










3 Answers
3






active

oldest

votes


















3














Quick and dirty expl3 implementation:



First you load the CSV file with LoadCSV{<label>}{<file>}. This command will open the file and load the contents of the CSV into <label>. The contents of the file are read verbatim (all catcodes are other (12), except for spaces (10)).



Then you get a field with GetCSV{<label>}{<line>}{<field>}.



Replacing your mockup code with:



LoadCSV {mycsv} {jobname.csv}
address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
phone[mobile]{GetCSV{mycsv}{2}{1}}
email{GetCSV{mycsv}{3}{1}}


it prints:




enter image description here




Full code:



RequirePackage{filecontents}
begin{filecontents*}{jobname.csv}
83 Fancy Avenue,Nowheresville,Gotham City 24061
123 456 7890
someone@xyz.com
end{filecontents*}

documentclass[11pt,a4paper,sans]{moderncv}

usepackage{expl3}
ExplSyntaxOn
ior_new:N l__krishna_ior_tmpa
cs_new:Npn krishna_csv_load:nn #1 #2
{
cs_if_free:cTF { l__krishna_ #1 _seq }
{ __krishna_csv_load:nn { l__krishna_ #1 } {#2} }
{ msg_error:nnn { krishna / csv } { name-used } {#1} }
}
cs_new:Npn __krishna_csv_load:nn #1 #2
{
ior_open:Nn l__krishna_ior_tmpa {#2}
seq_new:c { #1 _seq }
exp_args:Nc
__krishna_csv_read:N { #1 _seq }
ior_close:N l__krishna_ior_tmpa
}
cs_new:Npn __krishna_csv_read:N #1
{
ior_str_map_inline:Nn l__krishna_ior_tmpa
{ seq_put_right:Nn #1 {##1} }
}
cs_new:Npn krishna_csv_get:nnn #1 #2 #3
{
exp_args:Nf
clist_item:nn
{ seq_item:cn { l__krishna_ #1 _seq } {#2} }
{#3}
}
msg_new:nnn { krishna / csv } { name-used }
{ The~CSV~name~`#1'~is~already~taken }
cs_new_eq:NN LoadCSV krishna_csv_load:nn
cs_new_eq:NN GetCSV krishna_csv_get:nnn
ExplSyntaxOff

moderncvstyle{classic}

firstname{John}
familyname{Doe}

LoadCSV {mycsv} {jobname.csv}
address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
phone[mobile]{GetCSV{mycsv}{2}{1}}
email{GetCSV{mycsv}{3}{1}}

begin{document}
makecvtitle
end{document}


But Kut's idea of a .txt file with definitions is far simpler :)






share|improve this answer































    4














    Let us say we have the following code:



    documentclass[11pt,a4paper,sans]{moderncv}

    % moderncv themes
    moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
    moderncvcolor{blue}

    usepackage[utf8]{inputenc}

    usepackage[scale=0.75]{geometry}

    % personal data
    name{John}{Doe}
    title{Resumé title}
    address{street and number}{postcode city}{country}
    phone[mobile]{+1~(234)~567~890}
    phone[fixed]{+2~(345)~678~901}
    phone[fax]{+3~(456)~789~012}
    email{john@doe.org}
    homepage{www.johndoe.com}
    social[linkedin]{john.doe}
    social[twitter]{jdoe}
    social[github]{jdoe}
    extrainfo{additional information}
    photo[64pt][0.4pt]{example-image-a}
    quote{Some quote}

    setlength{footskip}{66pt}


    begin{document}

    makecvtitle

    section{Education}
    cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
    cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

    section{Master thesis}
    cvitem{title}{emph{Title}}
    cvitem{supervisors}{Supervisors}
    cvitem{description}{Short thesis abstract}

    end{document}


    Now move the personal data into a new file mydata.tex:



    name{John}{Doe}
    title{Resumé title}
    address{street and number}{postcode city}{country}
    phone[mobile]{+1~(234)~567~890}
    phone[fixed]{+2~(345)~678~901}
    phone[fax]{+3~(456)~789~012}
    email{john@doe.org}
    homepage{www.johndoe.com}
    social[linkedin]{john.doe}
    social[twitter]{jdoe}
    social[github]{jdoe}
    extrainfo{additional information}
    photo[64pt][0.4pt]{example-image-a}
    quote{Some quote}


    After that you can use the new code (simply used input instead the original personal datas):



    documentclass[11pt,a4paper,sans]{moderncv}

    % moderncv themes
    moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
    moderncvcolor{blue}

    usepackage[utf8]{inputenc}

    usepackage[scale=0.75]{geometry}

    % personal data
    input{mydata.tex} % <===========================================

    setlength{footskip}{66pt}


    begin{document}

    makecvtitle

    section{Education}
    cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
    cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

    section{Master thesis}
    cvitem{title}{emph{Title}}
    cvitem{supervisors}{Supervisors}
    cvitem{description}{Short thesis abstract}

    end{document}


    There are no differences in the both resulting pdfs ...



    Post the shown mydata.tex with the code for the cv on github and keep a copy of mydata.tex for your own purpose, of course filled with your real informations for a real cv ...






    share|improve this answer































      0














      With readarray (and listofitems included)



      RequirePackage{filecontents}
      begin{filecontents*}{personalinfo.csv}
      83 Fancy Avenue,Nowheresville,Gotham City 24061
      123 456 7890
      someone@xyz.com
      end{filecontents*}
      documentclass[11pt,a4paper]{moderncv}
      usepackage{readarray}

      moderncvstyle{classic}
      moderncvcolor{green}
      renewcommand{familydefault}{rmdefault}

      firstname{John}
      familyname{Doe}
      title{Title}

      readarraysepchar{\}
      readdef{personalinfo.csv}myrawdata
      setsepchar{\/,}
      readlist*{mydata}{myrawdata}

      address{mydata[1,1]}{mydata[1,2]}{mydata[1,3]}
      phone[mobile]{mydata[2,1]}
      email{mydata[3,1]}

      begin{document}
      makecvtitle
      end{document}


      enter image description here






      share|improve this answer

























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "85"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f474397%2fpopulate-information-from-a-csv-file-into-a-latex-document-specifically-into-th%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        3














        Quick and dirty expl3 implementation:



        First you load the CSV file with LoadCSV{<label>}{<file>}. This command will open the file and load the contents of the CSV into <label>. The contents of the file are read verbatim (all catcodes are other (12), except for spaces (10)).



        Then you get a field with GetCSV{<label>}{<line>}{<field>}.



        Replacing your mockup code with:



        LoadCSV {mycsv} {jobname.csv}
        address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
        phone[mobile]{GetCSV{mycsv}{2}{1}}
        email{GetCSV{mycsv}{3}{1}}


        it prints:




        enter image description here




        Full code:



        RequirePackage{filecontents}
        begin{filecontents*}{jobname.csv}
        83 Fancy Avenue,Nowheresville,Gotham City 24061
        123 456 7890
        someone@xyz.com
        end{filecontents*}

        documentclass[11pt,a4paper,sans]{moderncv}

        usepackage{expl3}
        ExplSyntaxOn
        ior_new:N l__krishna_ior_tmpa
        cs_new:Npn krishna_csv_load:nn #1 #2
        {
        cs_if_free:cTF { l__krishna_ #1 _seq }
        { __krishna_csv_load:nn { l__krishna_ #1 } {#2} }
        { msg_error:nnn { krishna / csv } { name-used } {#1} }
        }
        cs_new:Npn __krishna_csv_load:nn #1 #2
        {
        ior_open:Nn l__krishna_ior_tmpa {#2}
        seq_new:c { #1 _seq }
        exp_args:Nc
        __krishna_csv_read:N { #1 _seq }
        ior_close:N l__krishna_ior_tmpa
        }
        cs_new:Npn __krishna_csv_read:N #1
        {
        ior_str_map_inline:Nn l__krishna_ior_tmpa
        { seq_put_right:Nn #1 {##1} }
        }
        cs_new:Npn krishna_csv_get:nnn #1 #2 #3
        {
        exp_args:Nf
        clist_item:nn
        { seq_item:cn { l__krishna_ #1 _seq } {#2} }
        {#3}
        }
        msg_new:nnn { krishna / csv } { name-used }
        { The~CSV~name~`#1'~is~already~taken }
        cs_new_eq:NN LoadCSV krishna_csv_load:nn
        cs_new_eq:NN GetCSV krishna_csv_get:nnn
        ExplSyntaxOff

        moderncvstyle{classic}

        firstname{John}
        familyname{Doe}

        LoadCSV {mycsv} {jobname.csv}
        address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
        phone[mobile]{GetCSV{mycsv}{2}{1}}
        email{GetCSV{mycsv}{3}{1}}

        begin{document}
        makecvtitle
        end{document}


        But Kut's idea of a .txt file with definitions is far simpler :)






        share|improve this answer




























          3














          Quick and dirty expl3 implementation:



          First you load the CSV file with LoadCSV{<label>}{<file>}. This command will open the file and load the contents of the CSV into <label>. The contents of the file are read verbatim (all catcodes are other (12), except for spaces (10)).



          Then you get a field with GetCSV{<label>}{<line>}{<field>}.



          Replacing your mockup code with:



          LoadCSV {mycsv} {jobname.csv}
          address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
          phone[mobile]{GetCSV{mycsv}{2}{1}}
          email{GetCSV{mycsv}{3}{1}}


          it prints:




          enter image description here




          Full code:



          RequirePackage{filecontents}
          begin{filecontents*}{jobname.csv}
          83 Fancy Avenue,Nowheresville,Gotham City 24061
          123 456 7890
          someone@xyz.com
          end{filecontents*}

          documentclass[11pt,a4paper,sans]{moderncv}

          usepackage{expl3}
          ExplSyntaxOn
          ior_new:N l__krishna_ior_tmpa
          cs_new:Npn krishna_csv_load:nn #1 #2
          {
          cs_if_free:cTF { l__krishna_ #1 _seq }
          { __krishna_csv_load:nn { l__krishna_ #1 } {#2} }
          { msg_error:nnn { krishna / csv } { name-used } {#1} }
          }
          cs_new:Npn __krishna_csv_load:nn #1 #2
          {
          ior_open:Nn l__krishna_ior_tmpa {#2}
          seq_new:c { #1 _seq }
          exp_args:Nc
          __krishna_csv_read:N { #1 _seq }
          ior_close:N l__krishna_ior_tmpa
          }
          cs_new:Npn __krishna_csv_read:N #1
          {
          ior_str_map_inline:Nn l__krishna_ior_tmpa
          { seq_put_right:Nn #1 {##1} }
          }
          cs_new:Npn krishna_csv_get:nnn #1 #2 #3
          {
          exp_args:Nf
          clist_item:nn
          { seq_item:cn { l__krishna_ #1 _seq } {#2} }
          {#3}
          }
          msg_new:nnn { krishna / csv } { name-used }
          { The~CSV~name~`#1'~is~already~taken }
          cs_new_eq:NN LoadCSV krishna_csv_load:nn
          cs_new_eq:NN GetCSV krishna_csv_get:nnn
          ExplSyntaxOff

          moderncvstyle{classic}

          firstname{John}
          familyname{Doe}

          LoadCSV {mycsv} {jobname.csv}
          address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
          phone[mobile]{GetCSV{mycsv}{2}{1}}
          email{GetCSV{mycsv}{3}{1}}

          begin{document}
          makecvtitle
          end{document}


          But Kut's idea of a .txt file with definitions is far simpler :)






          share|improve this answer


























            3












            3








            3







            Quick and dirty expl3 implementation:



            First you load the CSV file with LoadCSV{<label>}{<file>}. This command will open the file and load the contents of the CSV into <label>. The contents of the file are read verbatim (all catcodes are other (12), except for spaces (10)).



            Then you get a field with GetCSV{<label>}{<line>}{<field>}.



            Replacing your mockup code with:



            LoadCSV {mycsv} {jobname.csv}
            address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
            phone[mobile]{GetCSV{mycsv}{2}{1}}
            email{GetCSV{mycsv}{3}{1}}


            it prints:




            enter image description here




            Full code:



            RequirePackage{filecontents}
            begin{filecontents*}{jobname.csv}
            83 Fancy Avenue,Nowheresville,Gotham City 24061
            123 456 7890
            someone@xyz.com
            end{filecontents*}

            documentclass[11pt,a4paper,sans]{moderncv}

            usepackage{expl3}
            ExplSyntaxOn
            ior_new:N l__krishna_ior_tmpa
            cs_new:Npn krishna_csv_load:nn #1 #2
            {
            cs_if_free:cTF { l__krishna_ #1 _seq }
            { __krishna_csv_load:nn { l__krishna_ #1 } {#2} }
            { msg_error:nnn { krishna / csv } { name-used } {#1} }
            }
            cs_new:Npn __krishna_csv_load:nn #1 #2
            {
            ior_open:Nn l__krishna_ior_tmpa {#2}
            seq_new:c { #1 _seq }
            exp_args:Nc
            __krishna_csv_read:N { #1 _seq }
            ior_close:N l__krishna_ior_tmpa
            }
            cs_new:Npn __krishna_csv_read:N #1
            {
            ior_str_map_inline:Nn l__krishna_ior_tmpa
            { seq_put_right:Nn #1 {##1} }
            }
            cs_new:Npn krishna_csv_get:nnn #1 #2 #3
            {
            exp_args:Nf
            clist_item:nn
            { seq_item:cn { l__krishna_ #1 _seq } {#2} }
            {#3}
            }
            msg_new:nnn { krishna / csv } { name-used }
            { The~CSV~name~`#1'~is~already~taken }
            cs_new_eq:NN LoadCSV krishna_csv_load:nn
            cs_new_eq:NN GetCSV krishna_csv_get:nnn
            ExplSyntaxOff

            moderncvstyle{classic}

            firstname{John}
            familyname{Doe}

            LoadCSV {mycsv} {jobname.csv}
            address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
            phone[mobile]{GetCSV{mycsv}{2}{1}}
            email{GetCSV{mycsv}{3}{1}}

            begin{document}
            makecvtitle
            end{document}


            But Kut's idea of a .txt file with definitions is far simpler :)






            share|improve this answer













            Quick and dirty expl3 implementation:



            First you load the CSV file with LoadCSV{<label>}{<file>}. This command will open the file and load the contents of the CSV into <label>. The contents of the file are read verbatim (all catcodes are other (12), except for spaces (10)).



            Then you get a field with GetCSV{<label>}{<line>}{<field>}.



            Replacing your mockup code with:



            LoadCSV {mycsv} {jobname.csv}
            address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
            phone[mobile]{GetCSV{mycsv}{2}{1}}
            email{GetCSV{mycsv}{3}{1}}


            it prints:




            enter image description here




            Full code:



            RequirePackage{filecontents}
            begin{filecontents*}{jobname.csv}
            83 Fancy Avenue,Nowheresville,Gotham City 24061
            123 456 7890
            someone@xyz.com
            end{filecontents*}

            documentclass[11pt,a4paper,sans]{moderncv}

            usepackage{expl3}
            ExplSyntaxOn
            ior_new:N l__krishna_ior_tmpa
            cs_new:Npn krishna_csv_load:nn #1 #2
            {
            cs_if_free:cTF { l__krishna_ #1 _seq }
            { __krishna_csv_load:nn { l__krishna_ #1 } {#2} }
            { msg_error:nnn { krishna / csv } { name-used } {#1} }
            }
            cs_new:Npn __krishna_csv_load:nn #1 #2
            {
            ior_open:Nn l__krishna_ior_tmpa {#2}
            seq_new:c { #1 _seq }
            exp_args:Nc
            __krishna_csv_read:N { #1 _seq }
            ior_close:N l__krishna_ior_tmpa
            }
            cs_new:Npn __krishna_csv_read:N #1
            {
            ior_str_map_inline:Nn l__krishna_ior_tmpa
            { seq_put_right:Nn #1 {##1} }
            }
            cs_new:Npn krishna_csv_get:nnn #1 #2 #3
            {
            exp_args:Nf
            clist_item:nn
            { seq_item:cn { l__krishna_ #1 _seq } {#2} }
            {#3}
            }
            msg_new:nnn { krishna / csv } { name-used }
            { The~CSV~name~`#1'~is~already~taken }
            cs_new_eq:NN LoadCSV krishna_csv_load:nn
            cs_new_eq:NN GetCSV krishna_csv_get:nnn
            ExplSyntaxOff

            moderncvstyle{classic}

            firstname{John}
            familyname{Doe}

            LoadCSV {mycsv} {jobname.csv}
            address{GetCSV{mycsv}{1}{1}}{GetCSV{mycsv}{1}{2}}{GetCSV{mycsv}{1}{3}}
            phone[mobile]{GetCSV{mycsv}{2}{1}}
            email{GetCSV{mycsv}{3}{1}}

            begin{document}
            makecvtitle
            end{document}


            But Kut's idea of a .txt file with definitions is far simpler :)







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 8 hours ago









            Phelype OleinikPhelype Oleinik

            22.8k54482




            22.8k54482























                4














                Let us say we have the following code:



                documentclass[11pt,a4paper,sans]{moderncv}

                % moderncv themes
                moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
                moderncvcolor{blue}

                usepackage[utf8]{inputenc}

                usepackage[scale=0.75]{geometry}

                % personal data
                name{John}{Doe}
                title{Resumé title}
                address{street and number}{postcode city}{country}
                phone[mobile]{+1~(234)~567~890}
                phone[fixed]{+2~(345)~678~901}
                phone[fax]{+3~(456)~789~012}
                email{john@doe.org}
                homepage{www.johndoe.com}
                social[linkedin]{john.doe}
                social[twitter]{jdoe}
                social[github]{jdoe}
                extrainfo{additional information}
                photo[64pt][0.4pt]{example-image-a}
                quote{Some quote}

                setlength{footskip}{66pt}


                begin{document}

                makecvtitle

                section{Education}
                cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
                cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

                section{Master thesis}
                cvitem{title}{emph{Title}}
                cvitem{supervisors}{Supervisors}
                cvitem{description}{Short thesis abstract}

                end{document}


                Now move the personal data into a new file mydata.tex:



                name{John}{Doe}
                title{Resumé title}
                address{street and number}{postcode city}{country}
                phone[mobile]{+1~(234)~567~890}
                phone[fixed]{+2~(345)~678~901}
                phone[fax]{+3~(456)~789~012}
                email{john@doe.org}
                homepage{www.johndoe.com}
                social[linkedin]{john.doe}
                social[twitter]{jdoe}
                social[github]{jdoe}
                extrainfo{additional information}
                photo[64pt][0.4pt]{example-image-a}
                quote{Some quote}


                After that you can use the new code (simply used input instead the original personal datas):



                documentclass[11pt,a4paper,sans]{moderncv}

                % moderncv themes
                moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
                moderncvcolor{blue}

                usepackage[utf8]{inputenc}

                usepackage[scale=0.75]{geometry}

                % personal data
                input{mydata.tex} % <===========================================

                setlength{footskip}{66pt}


                begin{document}

                makecvtitle

                section{Education}
                cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
                cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

                section{Master thesis}
                cvitem{title}{emph{Title}}
                cvitem{supervisors}{Supervisors}
                cvitem{description}{Short thesis abstract}

                end{document}


                There are no differences in the both resulting pdfs ...



                Post the shown mydata.tex with the code for the cv on github and keep a copy of mydata.tex for your own purpose, of course filled with your real informations for a real cv ...






                share|improve this answer




























                  4














                  Let us say we have the following code:



                  documentclass[11pt,a4paper,sans]{moderncv}

                  % moderncv themes
                  moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
                  moderncvcolor{blue}

                  usepackage[utf8]{inputenc}

                  usepackage[scale=0.75]{geometry}

                  % personal data
                  name{John}{Doe}
                  title{Resumé title}
                  address{street and number}{postcode city}{country}
                  phone[mobile]{+1~(234)~567~890}
                  phone[fixed]{+2~(345)~678~901}
                  phone[fax]{+3~(456)~789~012}
                  email{john@doe.org}
                  homepage{www.johndoe.com}
                  social[linkedin]{john.doe}
                  social[twitter]{jdoe}
                  social[github]{jdoe}
                  extrainfo{additional information}
                  photo[64pt][0.4pt]{example-image-a}
                  quote{Some quote}

                  setlength{footskip}{66pt}


                  begin{document}

                  makecvtitle

                  section{Education}
                  cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
                  cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

                  section{Master thesis}
                  cvitem{title}{emph{Title}}
                  cvitem{supervisors}{Supervisors}
                  cvitem{description}{Short thesis abstract}

                  end{document}


                  Now move the personal data into a new file mydata.tex:



                  name{John}{Doe}
                  title{Resumé title}
                  address{street and number}{postcode city}{country}
                  phone[mobile]{+1~(234)~567~890}
                  phone[fixed]{+2~(345)~678~901}
                  phone[fax]{+3~(456)~789~012}
                  email{john@doe.org}
                  homepage{www.johndoe.com}
                  social[linkedin]{john.doe}
                  social[twitter]{jdoe}
                  social[github]{jdoe}
                  extrainfo{additional information}
                  photo[64pt][0.4pt]{example-image-a}
                  quote{Some quote}


                  After that you can use the new code (simply used input instead the original personal datas):



                  documentclass[11pt,a4paper,sans]{moderncv}

                  % moderncv themes
                  moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
                  moderncvcolor{blue}

                  usepackage[utf8]{inputenc}

                  usepackage[scale=0.75]{geometry}

                  % personal data
                  input{mydata.tex} % <===========================================

                  setlength{footskip}{66pt}


                  begin{document}

                  makecvtitle

                  section{Education}
                  cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
                  cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

                  section{Master thesis}
                  cvitem{title}{emph{Title}}
                  cvitem{supervisors}{Supervisors}
                  cvitem{description}{Short thesis abstract}

                  end{document}


                  There are no differences in the both resulting pdfs ...



                  Post the shown mydata.tex with the code for the cv on github and keep a copy of mydata.tex for your own purpose, of course filled with your real informations for a real cv ...






                  share|improve this answer


























                    4












                    4








                    4







                    Let us say we have the following code:



                    documentclass[11pt,a4paper,sans]{moderncv}

                    % moderncv themes
                    moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
                    moderncvcolor{blue}

                    usepackage[utf8]{inputenc}

                    usepackage[scale=0.75]{geometry}

                    % personal data
                    name{John}{Doe}
                    title{Resumé title}
                    address{street and number}{postcode city}{country}
                    phone[mobile]{+1~(234)~567~890}
                    phone[fixed]{+2~(345)~678~901}
                    phone[fax]{+3~(456)~789~012}
                    email{john@doe.org}
                    homepage{www.johndoe.com}
                    social[linkedin]{john.doe}
                    social[twitter]{jdoe}
                    social[github]{jdoe}
                    extrainfo{additional information}
                    photo[64pt][0.4pt]{example-image-a}
                    quote{Some quote}

                    setlength{footskip}{66pt}


                    begin{document}

                    makecvtitle

                    section{Education}
                    cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
                    cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

                    section{Master thesis}
                    cvitem{title}{emph{Title}}
                    cvitem{supervisors}{Supervisors}
                    cvitem{description}{Short thesis abstract}

                    end{document}


                    Now move the personal data into a new file mydata.tex:



                    name{John}{Doe}
                    title{Resumé title}
                    address{street and number}{postcode city}{country}
                    phone[mobile]{+1~(234)~567~890}
                    phone[fixed]{+2~(345)~678~901}
                    phone[fax]{+3~(456)~789~012}
                    email{john@doe.org}
                    homepage{www.johndoe.com}
                    social[linkedin]{john.doe}
                    social[twitter]{jdoe}
                    social[github]{jdoe}
                    extrainfo{additional information}
                    photo[64pt][0.4pt]{example-image-a}
                    quote{Some quote}


                    After that you can use the new code (simply used input instead the original personal datas):



                    documentclass[11pt,a4paper,sans]{moderncv}

                    % moderncv themes
                    moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
                    moderncvcolor{blue}

                    usepackage[utf8]{inputenc}

                    usepackage[scale=0.75]{geometry}

                    % personal data
                    input{mydata.tex} % <===========================================

                    setlength{footskip}{66pt}


                    begin{document}

                    makecvtitle

                    section{Education}
                    cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
                    cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

                    section{Master thesis}
                    cvitem{title}{emph{Title}}
                    cvitem{supervisors}{Supervisors}
                    cvitem{description}{Short thesis abstract}

                    end{document}


                    There are no differences in the both resulting pdfs ...



                    Post the shown mydata.tex with the code for the cv on github and keep a copy of mydata.tex for your own purpose, of course filled with your real informations for a real cv ...






                    share|improve this answer













                    Let us say we have the following code:



                    documentclass[11pt,a4paper,sans]{moderncv}

                    % moderncv themes
                    moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
                    moderncvcolor{blue}

                    usepackage[utf8]{inputenc}

                    usepackage[scale=0.75]{geometry}

                    % personal data
                    name{John}{Doe}
                    title{Resumé title}
                    address{street and number}{postcode city}{country}
                    phone[mobile]{+1~(234)~567~890}
                    phone[fixed]{+2~(345)~678~901}
                    phone[fax]{+3~(456)~789~012}
                    email{john@doe.org}
                    homepage{www.johndoe.com}
                    social[linkedin]{john.doe}
                    social[twitter]{jdoe}
                    social[github]{jdoe}
                    extrainfo{additional information}
                    photo[64pt][0.4pt]{example-image-a}
                    quote{Some quote}

                    setlength{footskip}{66pt}


                    begin{document}

                    makecvtitle

                    section{Education}
                    cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
                    cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

                    section{Master thesis}
                    cvitem{title}{emph{Title}}
                    cvitem{supervisors}{Supervisors}
                    cvitem{description}{Short thesis abstract}

                    end{document}


                    Now move the personal data into a new file mydata.tex:



                    name{John}{Doe}
                    title{Resumé title}
                    address{street and number}{postcode city}{country}
                    phone[mobile]{+1~(234)~567~890}
                    phone[fixed]{+2~(345)~678~901}
                    phone[fax]{+3~(456)~789~012}
                    email{john@doe.org}
                    homepage{www.johndoe.com}
                    social[linkedin]{john.doe}
                    social[twitter]{jdoe}
                    social[github]{jdoe}
                    extrainfo{additional information}
                    photo[64pt][0.4pt]{example-image-a}
                    quote{Some quote}


                    After that you can use the new code (simply used input instead the original personal datas):



                    documentclass[11pt,a4paper,sans]{moderncv}

                    % moderncv themes
                    moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
                    moderncvcolor{blue}

                    usepackage[utf8]{inputenc}

                    usepackage[scale=0.75]{geometry}

                    % personal data
                    input{mydata.tex} % <===========================================

                    setlength{footskip}{66pt}


                    begin{document}

                    makecvtitle

                    section{Education}
                    cventry{year--year}{Degree}{Institution--3}{City--4}{textit{Grade}--5}{Description--6} % arguments 3 to 6 can be left empty
                    cventry{year--year}{Degree}{Institution}{City}{textit{Grade}}{Description}

                    section{Master thesis}
                    cvitem{title}{emph{Title}}
                    cvitem{supervisors}{Supervisors}
                    cvitem{description}{Short thesis abstract}

                    end{document}


                    There are no differences in the both resulting pdfs ...



                    Post the shown mydata.tex with the code for the cv on github and keep a copy of mydata.tex for your own purpose, of course filled with your real informations for a real cv ...







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 7 hours ago









                    KurtKurt

                    37.5k847162




                    37.5k847162























                        0














                        With readarray (and listofitems included)



                        RequirePackage{filecontents}
                        begin{filecontents*}{personalinfo.csv}
                        83 Fancy Avenue,Nowheresville,Gotham City 24061
                        123 456 7890
                        someone@xyz.com
                        end{filecontents*}
                        documentclass[11pt,a4paper]{moderncv}
                        usepackage{readarray}

                        moderncvstyle{classic}
                        moderncvcolor{green}
                        renewcommand{familydefault}{rmdefault}

                        firstname{John}
                        familyname{Doe}
                        title{Title}

                        readarraysepchar{\}
                        readdef{personalinfo.csv}myrawdata
                        setsepchar{\/,}
                        readlist*{mydata}{myrawdata}

                        address{mydata[1,1]}{mydata[1,2]}{mydata[1,3]}
                        phone[mobile]{mydata[2,1]}
                        email{mydata[3,1]}

                        begin{document}
                        makecvtitle
                        end{document}


                        enter image description here






                        share|improve this answer






























                          0














                          With readarray (and listofitems included)



                          RequirePackage{filecontents}
                          begin{filecontents*}{personalinfo.csv}
                          83 Fancy Avenue,Nowheresville,Gotham City 24061
                          123 456 7890
                          someone@xyz.com
                          end{filecontents*}
                          documentclass[11pt,a4paper]{moderncv}
                          usepackage{readarray}

                          moderncvstyle{classic}
                          moderncvcolor{green}
                          renewcommand{familydefault}{rmdefault}

                          firstname{John}
                          familyname{Doe}
                          title{Title}

                          readarraysepchar{\}
                          readdef{personalinfo.csv}myrawdata
                          setsepchar{\/,}
                          readlist*{mydata}{myrawdata}

                          address{mydata[1,1]}{mydata[1,2]}{mydata[1,3]}
                          phone[mobile]{mydata[2,1]}
                          email{mydata[3,1]}

                          begin{document}
                          makecvtitle
                          end{document}


                          enter image description here






                          share|improve this answer




























                            0












                            0








                            0







                            With readarray (and listofitems included)



                            RequirePackage{filecontents}
                            begin{filecontents*}{personalinfo.csv}
                            83 Fancy Avenue,Nowheresville,Gotham City 24061
                            123 456 7890
                            someone@xyz.com
                            end{filecontents*}
                            documentclass[11pt,a4paper]{moderncv}
                            usepackage{readarray}

                            moderncvstyle{classic}
                            moderncvcolor{green}
                            renewcommand{familydefault}{rmdefault}

                            firstname{John}
                            familyname{Doe}
                            title{Title}

                            readarraysepchar{\}
                            readdef{personalinfo.csv}myrawdata
                            setsepchar{\/,}
                            readlist*{mydata}{myrawdata}

                            address{mydata[1,1]}{mydata[1,2]}{mydata[1,3]}
                            phone[mobile]{mydata[2,1]}
                            email{mydata[3,1]}

                            begin{document}
                            makecvtitle
                            end{document}


                            enter image description here






                            share|improve this answer















                            With readarray (and listofitems included)



                            RequirePackage{filecontents}
                            begin{filecontents*}{personalinfo.csv}
                            83 Fancy Avenue,Nowheresville,Gotham City 24061
                            123 456 7890
                            someone@xyz.com
                            end{filecontents*}
                            documentclass[11pt,a4paper]{moderncv}
                            usepackage{readarray}

                            moderncvstyle{classic}
                            moderncvcolor{green}
                            renewcommand{familydefault}{rmdefault}

                            firstname{John}
                            familyname{Doe}
                            title{Title}

                            readarraysepchar{\}
                            readdef{personalinfo.csv}myrawdata
                            setsepchar{\/,}
                            readlist*{mydata}{myrawdata}

                            address{mydata[1,1]}{mydata[1,2]}{mydata[1,3]}
                            phone[mobile]{mydata[2,1]}
                            email{mydata[3,1]}

                            begin{document}
                            makecvtitle
                            end{document}


                            enter image description here







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 3 hours ago

























                            answered 3 hours ago









                            Steven B. SegletesSteven B. Segletes

                            154k9198405




                            154k9198405






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f474397%2fpopulate-information-from-a-csv-file-into-a-latex-document-specifically-into-th%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Magento 2 controller redirect on button click in phtml file

                                Polycentropodidae