Combine datetime2 and csvsimple












2















How can I make the following code compile:



documentclass{standalone} 
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtime{b}}
end{document}


Note that it does compile if I replace b by 00:00:01










share|improve this question



























    2















    How can I make the following code compile:



    documentclass{standalone} 
    usepackage{csvsimple}
    usepackage{datetime2}
    usepackage{filecontents}
    begin{filecontents*}{test.csv}
    a,b
    2019,00:00:00
    2019,00:00:01
    2020,00:00:02
    2018,00:00:03
    2018,00:00:04
    end{filecontents*}
    begin{document}
    csvreader[head to column names,tabular=llllll]{test.csv}{}
    {a&DTMtime{b}}
    end{document}


    Note that it does compile if I replace b by 00:00:01










    share|improve this question

























      2












      2








      2








      How can I make the following code compile:



      documentclass{standalone} 
      usepackage{csvsimple}
      usepackage{datetime2}
      usepackage{filecontents}
      begin{filecontents*}{test.csv}
      a,b
      2019,00:00:00
      2019,00:00:01
      2020,00:00:02
      2018,00:00:03
      2018,00:00:04
      end{filecontents*}
      begin{document}
      csvreader[head to column names,tabular=llllll]{test.csv}{}
      {a&DTMtime{b}}
      end{document}


      Note that it does compile if I replace b by 00:00:01










      share|improve this question














      How can I make the following code compile:



      documentclass{standalone} 
      usepackage{csvsimple}
      usepackage{datetime2}
      usepackage{filecontents}
      begin{filecontents*}{test.csv}
      a,b
      2019,00:00:00
      2019,00:00:01
      2020,00:00:02
      2018,00:00:03
      2018,00:00:04
      end{filecontents*}
      begin{document}
      csvreader[head to column names,tabular=llllll]{test.csv}{}
      {a&DTMtime{b}}
      end{document}


      Note that it does compile if I replace b by 00:00:01







      csvsimple datetime2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 18 at 21:04









      GerhardGerhard

      432




      432






















          1 Answer
          1






          active

          oldest

          votes


















          2














          The problem is that DTMtime expects its argument to already be expanded. You can see the problem if you say:



          deftest{00:00:00}
          DTMtime{test}


          this already throws an error. You need to expand first test and then run DTMtime on it. One way to do this is by saying



          edeftemp{noexpandDTMtime{test}}temp


          The command edef defines a new macro by recursively expanding the body of the macro. The command noexpand stops DTMtime from being expanded, so that temp gets defined as DTMtime{00:00:00} which then works as expected.



          I like to define this inside of a macro, say called eval:



          defeval#1{edeftemp{#1}temp}
          eval{noexpandDTMtime{test}}


          Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx which edef's the argument of a macro before calling it, so then exp_args:NxDTMtime{test} will expand test first and then run DTMtime on it. You can define a wrapper macro for DTMtime that always expands its argument first. Here's sample code for that:



          documentclass{standalone} 
          usepackage{expl3}
          usepackage{datetime2}
          ExplSyntaxOn
          cs_new:NpnDTMtimex { exp_args:NxDTMtime }
          ExplSyntaxOff

          begin{document}
          deftest{00:00:00}
          DTMtimex{test}
          end{document}


          Here's complete code:



          documentclass{standalone} 
          usepackage{csvsimple}
          usepackage{datetime2}
          usepackage{filecontents}
          begin{filecontents*}{test.csv}
          a,b
          2019,00:00:00
          2019,00:00:01
          2020,00:00:02
          2018,00:00:03
          2018,00:00:04
          end{filecontents*}

          defeval#1{edeftemp{#1}temp}
          defDTMtimex#1{eval{noexpandDTMtime{#1}}}

          begin{document}
          csvreader[head to column names,tabular=llllll]{test.csv}{}
          {a&DTMtimex{b}}
          end{document}





          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%2f480157%2fcombine-datetime2-and-csvsimple%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            The problem is that DTMtime expects its argument to already be expanded. You can see the problem if you say:



            deftest{00:00:00}
            DTMtime{test}


            this already throws an error. You need to expand first test and then run DTMtime on it. One way to do this is by saying



            edeftemp{noexpandDTMtime{test}}temp


            The command edef defines a new macro by recursively expanding the body of the macro. The command noexpand stops DTMtime from being expanded, so that temp gets defined as DTMtime{00:00:00} which then works as expected.



            I like to define this inside of a macro, say called eval:



            defeval#1{edeftemp{#1}temp}
            eval{noexpandDTMtime{test}}


            Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx which edef's the argument of a macro before calling it, so then exp_args:NxDTMtime{test} will expand test first and then run DTMtime on it. You can define a wrapper macro for DTMtime that always expands its argument first. Here's sample code for that:



            documentclass{standalone} 
            usepackage{expl3}
            usepackage{datetime2}
            ExplSyntaxOn
            cs_new:NpnDTMtimex { exp_args:NxDTMtime }
            ExplSyntaxOff

            begin{document}
            deftest{00:00:00}
            DTMtimex{test}
            end{document}


            Here's complete code:



            documentclass{standalone} 
            usepackage{csvsimple}
            usepackage{datetime2}
            usepackage{filecontents}
            begin{filecontents*}{test.csv}
            a,b
            2019,00:00:00
            2019,00:00:01
            2020,00:00:02
            2018,00:00:03
            2018,00:00:04
            end{filecontents*}

            defeval#1{edeftemp{#1}temp}
            defDTMtimex#1{eval{noexpandDTMtime{#1}}}

            begin{document}
            csvreader[head to column names,tabular=llllll]{test.csv}{}
            {a&DTMtimex{b}}
            end{document}





            share|improve this answer






























              2














              The problem is that DTMtime expects its argument to already be expanded. You can see the problem if you say:



              deftest{00:00:00}
              DTMtime{test}


              this already throws an error. You need to expand first test and then run DTMtime on it. One way to do this is by saying



              edeftemp{noexpandDTMtime{test}}temp


              The command edef defines a new macro by recursively expanding the body of the macro. The command noexpand stops DTMtime from being expanded, so that temp gets defined as DTMtime{00:00:00} which then works as expected.



              I like to define this inside of a macro, say called eval:



              defeval#1{edeftemp{#1}temp}
              eval{noexpandDTMtime{test}}


              Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx which edef's the argument of a macro before calling it, so then exp_args:NxDTMtime{test} will expand test first and then run DTMtime on it. You can define a wrapper macro for DTMtime that always expands its argument first. Here's sample code for that:



              documentclass{standalone} 
              usepackage{expl3}
              usepackage{datetime2}
              ExplSyntaxOn
              cs_new:NpnDTMtimex { exp_args:NxDTMtime }
              ExplSyntaxOff

              begin{document}
              deftest{00:00:00}
              DTMtimex{test}
              end{document}


              Here's complete code:



              documentclass{standalone} 
              usepackage{csvsimple}
              usepackage{datetime2}
              usepackage{filecontents}
              begin{filecontents*}{test.csv}
              a,b
              2019,00:00:00
              2019,00:00:01
              2020,00:00:02
              2018,00:00:03
              2018,00:00:04
              end{filecontents*}

              defeval#1{edeftemp{#1}temp}
              defDTMtimex#1{eval{noexpandDTMtime{#1}}}

              begin{document}
              csvreader[head to column names,tabular=llllll]{test.csv}{}
              {a&DTMtimex{b}}
              end{document}





              share|improve this answer




























                2












                2








                2







                The problem is that DTMtime expects its argument to already be expanded. You can see the problem if you say:



                deftest{00:00:00}
                DTMtime{test}


                this already throws an error. You need to expand first test and then run DTMtime on it. One way to do this is by saying



                edeftemp{noexpandDTMtime{test}}temp


                The command edef defines a new macro by recursively expanding the body of the macro. The command noexpand stops DTMtime from being expanded, so that temp gets defined as DTMtime{00:00:00} which then works as expected.



                I like to define this inside of a macro, say called eval:



                defeval#1{edeftemp{#1}temp}
                eval{noexpandDTMtime{test}}


                Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx which edef's the argument of a macro before calling it, so then exp_args:NxDTMtime{test} will expand test first and then run DTMtime on it. You can define a wrapper macro for DTMtime that always expands its argument first. Here's sample code for that:



                documentclass{standalone} 
                usepackage{expl3}
                usepackage{datetime2}
                ExplSyntaxOn
                cs_new:NpnDTMtimex { exp_args:NxDTMtime }
                ExplSyntaxOff

                begin{document}
                deftest{00:00:00}
                DTMtimex{test}
                end{document}


                Here's complete code:



                documentclass{standalone} 
                usepackage{csvsimple}
                usepackage{datetime2}
                usepackage{filecontents}
                begin{filecontents*}{test.csv}
                a,b
                2019,00:00:00
                2019,00:00:01
                2020,00:00:02
                2018,00:00:03
                2018,00:00:04
                end{filecontents*}

                defeval#1{edeftemp{#1}temp}
                defDTMtimex#1{eval{noexpandDTMtime{#1}}}

                begin{document}
                csvreader[head to column names,tabular=llllll]{test.csv}{}
                {a&DTMtimex{b}}
                end{document}





                share|improve this answer















                The problem is that DTMtime expects its argument to already be expanded. You can see the problem if you say:



                deftest{00:00:00}
                DTMtime{test}


                this already throws an error. You need to expand first test and then run DTMtime on it. One way to do this is by saying



                edeftemp{noexpandDTMtime{test}}temp


                The command edef defines a new macro by recursively expanding the body of the macro. The command noexpand stops DTMtime from being expanded, so that temp gets defined as DTMtime{00:00:00} which then works as expected.



                I like to define this inside of a macro, say called eval:



                defeval#1{edeftemp{#1}temp}
                eval{noexpandDTMtime{test}}


                Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx which edef's the argument of a macro before calling it, so then exp_args:NxDTMtime{test} will expand test first and then run DTMtime on it. You can define a wrapper macro for DTMtime that always expands its argument first. Here's sample code for that:



                documentclass{standalone} 
                usepackage{expl3}
                usepackage{datetime2}
                ExplSyntaxOn
                cs_new:NpnDTMtimex { exp_args:NxDTMtime }
                ExplSyntaxOff

                begin{document}
                deftest{00:00:00}
                DTMtimex{test}
                end{document}


                Here's complete code:



                documentclass{standalone} 
                usepackage{csvsimple}
                usepackage{datetime2}
                usepackage{filecontents}
                begin{filecontents*}{test.csv}
                a,b
                2019,00:00:00
                2019,00:00:01
                2020,00:00:02
                2018,00:00:03
                2018,00:00:04
                end{filecontents*}

                defeval#1{edeftemp{#1}temp}
                defDTMtimex#1{eval{noexpandDTMtime{#1}}}

                begin{document}
                csvreader[head to column names,tabular=llllll]{test.csv}{}
                {a&DTMtimex{b}}
                end{document}






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 18 at 21:19

























                answered Mar 18 at 21:12









                Hood ChathamHood Chatham

                4,3791428




                4,3791428






























                    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%2f480157%2fcombine-datetime2-and-csvsimple%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

                    How to change which sound is reproduced for terminal bell?

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents