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

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

Why might one *not* want to use a capo?

Is there an in-universe explanation given to the senior Imperial Navy Officers as to why Darth Vader serves Emperor Palpatine?

Group riding etiquette

RAID0 instead of RAID1 or 5, is this crazy?

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

Within what limits can the prime minister ask the queen to prorogue parliament?

What ways are there to "PEEK" memory sections in (different) BASIC(s)

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

Stolen MacBook should I worry about my data?

Why does AM radio react to IR remote?

Is allowing Barbarian features to work with Dex-based attacks imbalancing?

Normalized Malbolge to Malbolge translator

Adding and Multiplying Elements of a list together

Is the Amazon rainforest the "world's lungs"?

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

Looking for a plural noun related to ‘fulcrum’ or ‘pivot’ that denotes multiple things as crucial to success

How to deal with anxiety caused by dangerous riding conditions stemming from poor lane design and inconsiderate fellow road users?

web scraping images

Cutting numbers into a specific decimals

Spicing up a moment of peace

To what extent should we fear giving offense?

Why can't I identify major and minor chords?

Another "Ask One Question" Question



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 9 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

                                        Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

                                        The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

                                        19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу