Extracting values from an array object












1















How do i extract the first value from times and data from an array object and continue with the rest until i am done with all values?



PS S:FilesScripts> $memory

times data
----- ----
{1548401348221, 1548401358224, 1548401368227, 1548401378227...} {50.47999954223633, 50.47999954223633, 50.47999954223633, 50.47999954223633...}









share|improve this question

























  • How did you acquire $memory? May be easier to get in a step earlier possibly with ConvertFrom-Json What does $memory.gettype() return?

    – LotPings
    Jan 25 at 16:21


















1















How do i extract the first value from times and data from an array object and continue with the rest until i am done with all values?



PS S:FilesScripts> $memory

times data
----- ----
{1548401348221, 1548401358224, 1548401368227, 1548401378227...} {50.47999954223633, 50.47999954223633, 50.47999954223633, 50.47999954223633...}









share|improve this question

























  • How did you acquire $memory? May be easier to get in a step earlier possibly with ConvertFrom-Json What does $memory.gettype() return?

    – LotPings
    Jan 25 at 16:21
















1












1








1








How do i extract the first value from times and data from an array object and continue with the rest until i am done with all values?



PS S:FilesScripts> $memory

times data
----- ----
{1548401348221, 1548401358224, 1548401368227, 1548401378227...} {50.47999954223633, 50.47999954223633, 50.47999954223633, 50.47999954223633...}









share|improve this question
















How do i extract the first value from times and data from an array object and continue with the rest until i am done with all values?



PS S:FilesScripts> $memory

times data
----- ----
{1548401348221, 1548401358224, 1548401368227, 1548401378227...} {50.47999954223633, 50.47999954223633, 50.47999954223633, 50.47999954223633...}






powershell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 25 at 15:54









TDK

34513




34513










asked Jan 25 at 14:01









Powershell userPowershell user

61




61













  • How did you acquire $memory? May be easier to get in a step earlier possibly with ConvertFrom-Json What does $memory.gettype() return?

    – LotPings
    Jan 25 at 16:21





















  • How did you acquire $memory? May be easier to get in a step earlier possibly with ConvertFrom-Json What does $memory.gettype() return?

    – LotPings
    Jan 25 at 16:21



















How did you acquire $memory? May be easier to get in a step earlier possibly with ConvertFrom-Json What does $memory.gettype() return?

– LotPings
Jan 25 at 16:21







How did you acquire $memory? May be easier to get in a step earlier possibly with ConvertFrom-Json What does $memory.gettype() return?

– LotPings
Jan 25 at 16:21












1 Answer
1






active

oldest

votes


















1














One a bit clumsy way:



$times = $memory.times.trim('{}') -split ', '
$data = $memory.data.trim('{}') -split ', '

$newMemory = for ($i=0;$i -lt $times.count;$i++){
[PSCUstomObject]@{
times = $times[$i]
data = $data[$i]
}
}

$newMemory

times data
----- ----
1548401348221 50.47999954223633
1548401358224 50.47999954223633
1548401368227 50.47999954223633
1548401378227 50.47999954223633





share|improve this answer
























  • Thanks for the quick response and Appreciate it. I ran into below error when i tried to trim it. Method invocation failed because [System.Int64] does not contain a method named 'trim'. $Memory appears to be a system object and i might have to convert it

    – Powershell user
    Jan 25 at 17:34













  • Please EDIT your question to contain the information I asked for in above comment. Eventually just use $times = $memory.times etc.

    – LotPings
    Jan 25 at 17:46











  • Sorry, i just noticed your question. that did the trick. thanks again

    – Powershell user
    Jan 25 at 17:50











  • To be of any use for followup readers you should elaborate how you solved the problem - otherwise better delete the question.

    – LotPings
    Jan 25 at 18:56











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f1398378%2fextracting-values-from-an-array-object%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









1














One a bit clumsy way:



$times = $memory.times.trim('{}') -split ', '
$data = $memory.data.trim('{}') -split ', '

$newMemory = for ($i=0;$i -lt $times.count;$i++){
[PSCUstomObject]@{
times = $times[$i]
data = $data[$i]
}
}

$newMemory

times data
----- ----
1548401348221 50.47999954223633
1548401358224 50.47999954223633
1548401368227 50.47999954223633
1548401378227 50.47999954223633





share|improve this answer
























  • Thanks for the quick response and Appreciate it. I ran into below error when i tried to trim it. Method invocation failed because [System.Int64] does not contain a method named 'trim'. $Memory appears to be a system object and i might have to convert it

    – Powershell user
    Jan 25 at 17:34













  • Please EDIT your question to contain the information I asked for in above comment. Eventually just use $times = $memory.times etc.

    – LotPings
    Jan 25 at 17:46











  • Sorry, i just noticed your question. that did the trick. thanks again

    – Powershell user
    Jan 25 at 17:50











  • To be of any use for followup readers you should elaborate how you solved the problem - otherwise better delete the question.

    – LotPings
    Jan 25 at 18:56
















1














One a bit clumsy way:



$times = $memory.times.trim('{}') -split ', '
$data = $memory.data.trim('{}') -split ', '

$newMemory = for ($i=0;$i -lt $times.count;$i++){
[PSCUstomObject]@{
times = $times[$i]
data = $data[$i]
}
}

$newMemory

times data
----- ----
1548401348221 50.47999954223633
1548401358224 50.47999954223633
1548401368227 50.47999954223633
1548401378227 50.47999954223633





share|improve this answer
























  • Thanks for the quick response and Appreciate it. I ran into below error when i tried to trim it. Method invocation failed because [System.Int64] does not contain a method named 'trim'. $Memory appears to be a system object and i might have to convert it

    – Powershell user
    Jan 25 at 17:34













  • Please EDIT your question to contain the information I asked for in above comment. Eventually just use $times = $memory.times etc.

    – LotPings
    Jan 25 at 17:46











  • Sorry, i just noticed your question. that did the trick. thanks again

    – Powershell user
    Jan 25 at 17:50











  • To be of any use for followup readers you should elaborate how you solved the problem - otherwise better delete the question.

    – LotPings
    Jan 25 at 18:56














1












1








1







One a bit clumsy way:



$times = $memory.times.trim('{}') -split ', '
$data = $memory.data.trim('{}') -split ', '

$newMemory = for ($i=0;$i -lt $times.count;$i++){
[PSCUstomObject]@{
times = $times[$i]
data = $data[$i]
}
}

$newMemory

times data
----- ----
1548401348221 50.47999954223633
1548401358224 50.47999954223633
1548401368227 50.47999954223633
1548401378227 50.47999954223633





share|improve this answer













One a bit clumsy way:



$times = $memory.times.trim('{}') -split ', '
$data = $memory.data.trim('{}') -split ', '

$newMemory = for ($i=0;$i -lt $times.count;$i++){
[PSCUstomObject]@{
times = $times[$i]
data = $data[$i]
}
}

$newMemory

times data
----- ----
1548401348221 50.47999954223633
1548401358224 50.47999954223633
1548401368227 50.47999954223633
1548401378227 50.47999954223633






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 25 at 16:57









LotPingsLotPings

5,0301823




5,0301823













  • Thanks for the quick response and Appreciate it. I ran into below error when i tried to trim it. Method invocation failed because [System.Int64] does not contain a method named 'trim'. $Memory appears to be a system object and i might have to convert it

    – Powershell user
    Jan 25 at 17:34













  • Please EDIT your question to contain the information I asked for in above comment. Eventually just use $times = $memory.times etc.

    – LotPings
    Jan 25 at 17:46











  • Sorry, i just noticed your question. that did the trick. thanks again

    – Powershell user
    Jan 25 at 17:50











  • To be of any use for followup readers you should elaborate how you solved the problem - otherwise better delete the question.

    – LotPings
    Jan 25 at 18:56



















  • Thanks for the quick response and Appreciate it. I ran into below error when i tried to trim it. Method invocation failed because [System.Int64] does not contain a method named 'trim'. $Memory appears to be a system object and i might have to convert it

    – Powershell user
    Jan 25 at 17:34













  • Please EDIT your question to contain the information I asked for in above comment. Eventually just use $times = $memory.times etc.

    – LotPings
    Jan 25 at 17:46











  • Sorry, i just noticed your question. that did the trick. thanks again

    – Powershell user
    Jan 25 at 17:50











  • To be of any use for followup readers you should elaborate how you solved the problem - otherwise better delete the question.

    – LotPings
    Jan 25 at 18:56

















Thanks for the quick response and Appreciate it. I ran into below error when i tried to trim it. Method invocation failed because [System.Int64] does not contain a method named 'trim'. $Memory appears to be a system object and i might have to convert it

– Powershell user
Jan 25 at 17:34







Thanks for the quick response and Appreciate it. I ran into below error when i tried to trim it. Method invocation failed because [System.Int64] does not contain a method named 'trim'. $Memory appears to be a system object and i might have to convert it

– Powershell user
Jan 25 at 17:34















Please EDIT your question to contain the information I asked for in above comment. Eventually just use $times = $memory.times etc.

– LotPings
Jan 25 at 17:46





Please EDIT your question to contain the information I asked for in above comment. Eventually just use $times = $memory.times etc.

– LotPings
Jan 25 at 17:46













Sorry, i just noticed your question. that did the trick. thanks again

– Powershell user
Jan 25 at 17:50





Sorry, i just noticed your question. that did the trick. thanks again

– Powershell user
Jan 25 at 17:50













To be of any use for followup readers you should elaborate how you solved the problem - otherwise better delete the question.

– LotPings
Jan 25 at 18:56





To be of any use for followup readers you should elaborate how you solved the problem - otherwise better delete the question.

– LotPings
Jan 25 at 18:56


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • 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%2fsuperuser.com%2fquestions%2f1398378%2fextracting-values-from-an-array-object%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

Plaza Victoria

In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...