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;
$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"
list-manipulation
New contributor
$endgroup$
add a comment |
$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"
list-manipulation
New contributor
$endgroup$
add a comment |
$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"
list-manipulation
New contributor
$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
list-manipulation
New contributor
New contributor
edited 8 hours ago
march
17.8k2 gold badges29 silver badges70 bronze badges
17.8k2 gold badges29 silver badges70 bronze badges
New contributor
asked 8 hours ago
user67167user67167
161 bronze badge
161 bronze badge
New contributor
New contributor
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
$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"
"21:00:00" "2018/28/8"
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"
$endgroup$
add a comment |
$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
New contributor
$endgroup$
add a comment |
$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
.
$endgroup$
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
$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"
"21:00:00" "2018/28/8"
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"
$endgroup$
add a comment |
$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"
"21:00:00" "2018/28/8"
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"
$endgroup$
add a comment |
$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"
"21:00:00" "2018/28/8"
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"
$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"
"21:00:00" "2018/28/8"
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"
edited 7 hours ago
answered 8 hours ago
kglrkglr
214k10 gold badges245 silver badges489 bronze badges
214k10 gold badges245 silver badges489 bronze badges
add a comment |
add a comment |
$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
New contributor
$endgroup$
add a comment |
$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
New contributor
$endgroup$
add a comment |
$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
New contributor
$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
New contributor
New contributor
answered 6 hours ago
S.SchroederS.Schroeder
212 bronze badges
212 bronze badges
New contributor
New contributor
add a comment |
add a comment |
$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
.
$endgroup$
add a comment |
$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
.
$endgroup$
add a comment |
$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
.
$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
.
answered 3 hours ago
Carl WollCarl Woll
89.4k3 gold badges117 silver badges228 bronze badges
89.4k3 gold badges117 silver badges228 bronze badges
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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