Adding and Multiplying Elements of a list togetherElegant operations on matrix rows and columnsReshape vectors exactly like in MATLABHow to use ImageMultiply[] over a list of strings?Importing, sorting and exporting listsHow to import data from a .mat or a .txt file and manipulate dimensionsUsing HoldForm for a changing listRecursively appending elements to a listReplacing and restructuring list elements in placeHow to multiply nested lists by a list with the same length?Multiplying elements of a list

Alternatives to Network Backup

Coupling two 15 Amp circuit breaker for 20 Amp

What's the point of fighting monsters in Zelda BotW?

Another "Ask One Question" Question

Printing a list as "a, b, c." using Python

Why is there not a willingness from the world to step in between Pakistan and India?

Defending Castle from Zombies

Why does this London Underground poster from 1924 have a Star of David atop a Christmas tree?

Normalized Malbolge to Malbolge translator

If I said I had $100 when asked, but I actually had $200, would I be lying by omission?

Did ancient peoples ever hide their treasure behind puzzles?

Is it unusual for a math department not to have a mail/web server?

Is there a word or phrase that means "use other people's wifi or Internet service without consent"?

Why nature prefers simultaneous events?

Fantasy Macro Economics: What would Merfolk trade for?

web scraping images

Why is 3/4 a simple meter while 6/8 is a compound meter?

Why is the Grievance Studies affair considered to be research requiring IRB approval?

Would it be better to write a trilogy over a much longer series?

How to say "I only speak one language which is English" in French?

STM32 cannot reach individual registers and pins as PIC

What checks exist against overuse of presidential pardons in the USA?

Was the six engine Boeing-747 ever thought about?

SQL Server - How to achieve READCOMMITED and NOLOCK at the same time?



Adding and Multiplying Elements of a list together


Elegant operations on matrix rows and columnsReshape vectors exactly like in MATLABHow to use ImageMultiply[] over a list of strings?Importing, sorting and exporting listsHow to import data from a .mat or a .txt file and manipulate dimensionsUsing HoldForm for a changing listRecursively appending elements to a listReplacing and restructuring list elements in placeHow to multiply nested lists by a list with the same length?Multiplying elements of a list






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3












$begingroup$


I am trying to manipulate a file to change the time into UnixTime and for that I need the date and time but of course it needs to be date first and time second. I've tried multiplying and I've tried adding, i've even changed the order of which i add and multiply but it always puts the time first. What can I do to fix this.



out = Import["*file name is not really that relevant", "Table"];
out2 = Drop[out, 3];
date, time, timeElapsed, TPM1, TPM25, TPM10, PM1, PM25, PM10, CO2, TempC, Humidity, NO, NO2, O3, CO2raw, workNO2, auxNO2, workO3, auxO3, labNO, labNO2, labO3, labCO2, labTPM25, labPM25 = Transpose[out2];
realDate = StringDrop[#, -1] & /@ date;
realTime = StringDrop[#, -1] & /@ time;
realTime (realDate)


This prints a list with a bunch of values but the elements all look like "12:00:00 2018/28/8" instead of "2018/28/8 12:00:00"










share|improve this question









New contributor



user67167 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$




















    3












    $begingroup$


    I am trying to manipulate a file to change the time into UnixTime and for that I need the date and time but of course it needs to be date first and time second. I've tried multiplying and I've tried adding, i've even changed the order of which i add and multiply but it always puts the time first. What can I do to fix this.



    out = Import["*file name is not really that relevant", "Table"];
    out2 = Drop[out, 3];
    date, time, timeElapsed, TPM1, TPM25, TPM10, PM1, PM25, PM10, CO2, TempC, Humidity, NO, NO2, O3, CO2raw, workNO2, auxNO2, workO3, auxO3, labNO, labNO2, labO3, labCO2, labTPM25, labPM25 = Transpose[out2];
    realDate = StringDrop[#, -1] & /@ date;
    realTime = StringDrop[#, -1] & /@ time;
    realTime (realDate)


    This prints a list with a bunch of values but the elements all look like "12:00:00 2018/28/8" instead of "2018/28/8 12:00:00"










    share|improve this question









    New contributor



    user67167 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






    $endgroup$
















      3












      3








      3





      $begingroup$


      I am trying to manipulate a file to change the time into UnixTime and for that I need the date and time but of course it needs to be date first and time second. I've tried multiplying and I've tried adding, i've even changed the order of which i add and multiply but it always puts the time first. What can I do to fix this.



      out = Import["*file name is not really that relevant", "Table"];
      out2 = Drop[out, 3];
      date, time, timeElapsed, TPM1, TPM25, TPM10, PM1, PM25, PM10, CO2, TempC, Humidity, NO, NO2, O3, CO2raw, workNO2, auxNO2, workO3, auxO3, labNO, labNO2, labO3, labCO2, labTPM25, labPM25 = Transpose[out2];
      realDate = StringDrop[#, -1] & /@ date;
      realTime = StringDrop[#, -1] & /@ time;
      realTime (realDate)


      This prints a list with a bunch of values but the elements all look like "12:00:00 2018/28/8" instead of "2018/28/8 12:00:00"










      share|improve this question









      New contributor



      user67167 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      $endgroup$




      I am trying to manipulate a file to change the time into UnixTime and for that I need the date and time but of course it needs to be date first and time second. I've tried multiplying and I've tried adding, i've even changed the order of which i add and multiply but it always puts the time first. What can I do to fix this.



      out = Import["*file name is not really that relevant", "Table"];
      out2 = Drop[out, 3];
      date, time, timeElapsed, TPM1, TPM25, TPM10, PM1, PM25, PM10, CO2, TempC, Humidity, NO, NO2, O3, CO2raw, workNO2, auxNO2, workO3, auxO3, labNO, labNO2, labO3, labCO2, labTPM25, labPM25 = Transpose[out2];
      realDate = StringDrop[#, -1] & /@ date;
      realTime = StringDrop[#, -1] & /@ time;
      realTime (realDate)


      This prints a list with a bunch of values but the elements all look like "12:00:00 2018/28/8" instead of "2018/28/8 12:00:00"







      list-manipulation






      share|improve this question









      New contributor



      user67167 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question









      New contributor



      user67167 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question








      edited 8 hours ago









      march

      17.8k2 gold badges29 silver badges70 bronze badges




      17.8k2 gold badges29 silver badges70 bronze badges






      New contributor



      user67167 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 8 hours ago









      user67167user67167

      161 bronze badge




      161 bronze badge




      New contributor



      user67167 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      user67167 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

























          3 Answers
          3






          active

          oldest

          votes


















          4













          $begingroup$

          realdate, realtime = "2018/28/8" , "12:00:00" ;


          Since realdate and realtime are strings, you can use StringJoin or StringRiffle to get a single string:



          datetime = StringJoin[realdate, " ", realtime]



          "2018/28/8 12:00:00"




          datetime = StringRiffle[realdate, realtime]



          "2018/28/8 12:00:00"




          To have datetime work as a proper date string, specify the date format as



          dformat = "Year", "/", "Month", "/", "Day", " ", "Hour", ":", "Minute", ":", "Second";

          dl = DateList[datetime, dformat]



          2020, 4, 8, 12, 0, 0.




          ds = DateString[dl, dformat]



          "2020/04/08 12:00:00"




          What happens if you multiply/add two strings?



          "12:00:00" "2018/28/8" 


          enter image description here



          "21:00:00" "2018/28/8" 


          enter image description here



          just as in



          y x



          x y




          y + x



          x + y




          because both operators Plus and Times are Orderless and




          "Elements of an expression whose head is orderless are sorted into standard order"







          share|improve this answer











          $endgroup$






















            2













            $begingroup$

            Alternatively, you could just use your current list of ("12:00:00 2018/28/8") formatted DateTimes and pass each element in the list to Interpreter which will correctly parse each into a DateObject.



            For example:



            Interpreter["DateTime"]["12:00:00 2018/28/8"]


            returns the correct DateObject



            UnixTime can handle DateObjects. Using your example:



            UnixTime[Interpreter["DateTime"]["12:00:00 2018/28/8"]]



            1535436000







            share|improve this answer








            New contributor



            S.Schroeder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





            $endgroup$






















              0













              $begingroup$

              You could add the element order to your input string, e.g.:



              string = "12:00:00 2018/28/8";
              UnixTime[
              string,
              "Hour","Minute","Second","Year","Day","Month"
              ]



              1535482800




              You can adjust the assumed time zone as specified in the documentation for UnixTime.






              share|improve this answer









              $endgroup$

















                Your Answer








                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "387"
                ;
                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
                );



                );






                user67167 is a new contributor. Be nice, and check out our Code of Conduct.









                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f204474%2fadding-and-multiplying-elements-of-a-list-together%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









                4













                $begingroup$

                realdate, realtime = "2018/28/8" , "12:00:00" ;


                Since realdate and realtime are strings, you can use StringJoin or StringRiffle to get a single string:



                datetime = StringJoin[realdate, " ", realtime]



                "2018/28/8 12:00:00"




                datetime = StringRiffle[realdate, realtime]



                "2018/28/8 12:00:00"




                To have datetime work as a proper date string, specify the date format as



                dformat = "Year", "/", "Month", "/", "Day", " ", "Hour", ":", "Minute", ":", "Second";

                dl = DateList[datetime, dformat]



                2020, 4, 8, 12, 0, 0.




                ds = DateString[dl, dformat]



                "2020/04/08 12:00:00"




                What happens if you multiply/add two strings?



                "12:00:00" "2018/28/8" 


                enter image description here



                "21:00:00" "2018/28/8" 


                enter image description here



                just as in



                y x



                x y




                y + x



                x + y




                because both operators Plus and Times are Orderless and




                "Elements of an expression whose head is orderless are sorted into standard order"







                share|improve this answer











                $endgroup$



















                  4













                  $begingroup$

                  realdate, realtime = "2018/28/8" , "12:00:00" ;


                  Since realdate and realtime are strings, you can use StringJoin or StringRiffle to get a single string:



                  datetime = StringJoin[realdate, " ", realtime]



                  "2018/28/8 12:00:00"




                  datetime = StringRiffle[realdate, realtime]



                  "2018/28/8 12:00:00"




                  To have datetime work as a proper date string, specify the date format as



                  dformat = "Year", "/", "Month", "/", "Day", " ", "Hour", ":", "Minute", ":", "Second";

                  dl = DateList[datetime, dformat]



                  2020, 4, 8, 12, 0, 0.




                  ds = DateString[dl, dformat]



                  "2020/04/08 12:00:00"




                  What happens if you multiply/add two strings?



                  "12:00:00" "2018/28/8" 


                  enter image description here



                  "21:00:00" "2018/28/8" 


                  enter image description here



                  just as in



                  y x



                  x y




                  y + x



                  x + y




                  because both operators Plus and Times are Orderless and




                  "Elements of an expression whose head is orderless are sorted into standard order"







                  share|improve this answer











                  $endgroup$

















                    4














                    4










                    4







                    $begingroup$

                    realdate, realtime = "2018/28/8" , "12:00:00" ;


                    Since realdate and realtime are strings, you can use StringJoin or StringRiffle to get a single string:



                    datetime = StringJoin[realdate, " ", realtime]



                    "2018/28/8 12:00:00"




                    datetime = StringRiffle[realdate, realtime]



                    "2018/28/8 12:00:00"




                    To have datetime work as a proper date string, specify the date format as



                    dformat = "Year", "/", "Month", "/", "Day", " ", "Hour", ":", "Minute", ":", "Second";

                    dl = DateList[datetime, dformat]



                    2020, 4, 8, 12, 0, 0.




                    ds = DateString[dl, dformat]



                    "2020/04/08 12:00:00"




                    What happens if you multiply/add two strings?



                    "12:00:00" "2018/28/8" 


                    enter image description here



                    "21:00:00" "2018/28/8" 


                    enter image description here



                    just as in



                    y x



                    x y




                    y + x



                    x + y




                    because both operators Plus and Times are Orderless and




                    "Elements of an expression whose head is orderless are sorted into standard order"







                    share|improve this answer











                    $endgroup$



                    realdate, realtime = "2018/28/8" , "12:00:00" ;


                    Since realdate and realtime are strings, you can use StringJoin or StringRiffle to get a single string:



                    datetime = StringJoin[realdate, " ", realtime]



                    "2018/28/8 12:00:00"




                    datetime = StringRiffle[realdate, realtime]



                    "2018/28/8 12:00:00"




                    To have datetime work as a proper date string, specify the date format as



                    dformat = "Year", "/", "Month", "/", "Day", " ", "Hour", ":", "Minute", ":", "Second";

                    dl = DateList[datetime, dformat]



                    2020, 4, 8, 12, 0, 0.




                    ds = DateString[dl, dformat]



                    "2020/04/08 12:00:00"




                    What happens if you multiply/add two strings?



                    "12:00:00" "2018/28/8" 


                    enter image description here



                    "21:00:00" "2018/28/8" 


                    enter image description here



                    just as in



                    y x



                    x y




                    y + x



                    x + y




                    because both operators Plus and Times are Orderless and




                    "Elements of an expression whose head is orderless are sorted into standard order"








                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 7 hours ago

























                    answered 8 hours ago









                    kglrkglr

                    214k10 gold badges245 silver badges489 bronze badges




                    214k10 gold badges245 silver badges489 bronze badges


























                        2













                        $begingroup$

                        Alternatively, you could just use your current list of ("12:00:00 2018/28/8") formatted DateTimes and pass each element in the list to Interpreter which will correctly parse each into a DateObject.



                        For example:



                        Interpreter["DateTime"]["12:00:00 2018/28/8"]


                        returns the correct DateObject



                        UnixTime can handle DateObjects. Using your example:



                        UnixTime[Interpreter["DateTime"]["12:00:00 2018/28/8"]]



                        1535436000







                        share|improve this answer








                        New contributor



                        S.Schroeder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.





                        $endgroup$



















                          2













                          $begingroup$

                          Alternatively, you could just use your current list of ("12:00:00 2018/28/8") formatted DateTimes and pass each element in the list to Interpreter which will correctly parse each into a DateObject.



                          For example:



                          Interpreter["DateTime"]["12:00:00 2018/28/8"]


                          returns the correct DateObject



                          UnixTime can handle DateObjects. Using your example:



                          UnixTime[Interpreter["DateTime"]["12:00:00 2018/28/8"]]



                          1535436000







                          share|improve this answer








                          New contributor



                          S.Schroeder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          $endgroup$

















                            2














                            2










                            2







                            $begingroup$

                            Alternatively, you could just use your current list of ("12:00:00 2018/28/8") formatted DateTimes and pass each element in the list to Interpreter which will correctly parse each into a DateObject.



                            For example:



                            Interpreter["DateTime"]["12:00:00 2018/28/8"]


                            returns the correct DateObject



                            UnixTime can handle DateObjects. Using your example:



                            UnixTime[Interpreter["DateTime"]["12:00:00 2018/28/8"]]



                            1535436000







                            share|improve this answer








                            New contributor



                            S.Schroeder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            $endgroup$



                            Alternatively, you could just use your current list of ("12:00:00 2018/28/8") formatted DateTimes and pass each element in the list to Interpreter which will correctly parse each into a DateObject.



                            For example:



                            Interpreter["DateTime"]["12:00:00 2018/28/8"]


                            returns the correct DateObject



                            UnixTime can handle DateObjects. Using your example:



                            UnixTime[Interpreter["DateTime"]["12:00:00 2018/28/8"]]



                            1535436000








                            share|improve this answer








                            New contributor



                            S.Schroeder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.








                            share|improve this answer



                            share|improve this answer






                            New contributor



                            S.Schroeder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.








                            answered 6 hours ago









                            S.SchroederS.Schroeder

                            212 bronze badges




                            212 bronze badges




                            New contributor



                            S.Schroeder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.




                            New contributor




                            S.Schroeder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.


























                                0













                                $begingroup$

                                You could add the element order to your input string, e.g.:



                                string = "12:00:00 2018/28/8";
                                UnixTime[
                                string,
                                "Hour","Minute","Second","Year","Day","Month"
                                ]



                                1535482800




                                You can adjust the assumed time zone as specified in the documentation for UnixTime.






                                share|improve this answer









                                $endgroup$



















                                  0













                                  $begingroup$

                                  You could add the element order to your input string, e.g.:



                                  string = "12:00:00 2018/28/8";
                                  UnixTime[
                                  string,
                                  "Hour","Minute","Second","Year","Day","Month"
                                  ]



                                  1535482800




                                  You can adjust the assumed time zone as specified in the documentation for UnixTime.






                                  share|improve this answer









                                  $endgroup$

















                                    0














                                    0










                                    0







                                    $begingroup$

                                    You could add the element order to your input string, e.g.:



                                    string = "12:00:00 2018/28/8";
                                    UnixTime[
                                    string,
                                    "Hour","Minute","Second","Year","Day","Month"
                                    ]



                                    1535482800




                                    You can adjust the assumed time zone as specified in the documentation for UnixTime.






                                    share|improve this answer









                                    $endgroup$



                                    You could add the element order to your input string, e.g.:



                                    string = "12:00:00 2018/28/8";
                                    UnixTime[
                                    string,
                                    "Hour","Minute","Second","Year","Day","Month"
                                    ]



                                    1535482800




                                    You can adjust the assumed time zone as specified in the documentation for UnixTime.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 3 hours ago









                                    Carl WollCarl Woll

                                    89.4k3 gold badges117 silver badges228 bronze badges




                                    89.4k3 gold badges117 silver badges228 bronze badges























                                        user67167 is a new contributor. Be nice, and check out our Code of Conduct.









                                        draft saved

                                        draft discarded


















                                        user67167 is a new contributor. Be nice, and check out our Code of Conduct.












                                        user67167 is a new contributor. Be nice, and check out our Code of Conduct.











                                        user67167 is a new contributor. Be nice, and check out our Code of Conduct.














                                        Thanks for contributing an answer to Mathematica 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.

                                        Use MathJax to format equations. MathJax reference.


                                        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%2fmathematica.stackexchange.com%2fquestions%2f204474%2fadding-and-multiplying-elements-of-a-list-together%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

                                        Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                        Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                        Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її