Splitting and extracting values from a row?How to concatenate text from multiple rows into a single text string in SQL server?How do you split a list into evenly sized chunks?Extracting extension from filename in PythonHow do I sort a dictionary by value?How to access environment variable values?Use a list of values to select rows from a pandas dataframeDelete column from pandas DataFrame by column name“Large data” work flows using pandasHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandas

Thesis' "Future Work" section – is it acceptable to omit personal involvement in a mentioned project?

Are there variations of the regular runtimes of the Big-O-Notation?

Can I do brevets (long distance rides) on my hybrid bike? If yes, how to start?

On what legal basis did the UK remove the 'European Union' from its passport?

How can a Lich look like a human without magic?

Why can't RGB or bicolour LEDs produce a decent yellow?

How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?

Limit of an integral vs Limit of the integrand

How do I compare the result of "1d20+x, with advantage" to "1d20+y, without advantage", assuming x < y?

Can you book a one-way ticket to the UK on a visa?

International Code of Ethics for order of co-authors in research papers

Is the schwa sound consistent?

Is a vertical stabiliser needed for straight line flight in a glider?

How could a Lich maintain the appearance of being alive without magic?

Remove everything except csv file Bash Script

What are some possible reasons that a father's name is missing from a birth certificate - England?

How can this pool heater gas line be disconnected?

Pre-1993 comic in which Wolverine's claws were turned to rubber?

Control variables and other independent variables

How are Core iX names like Core i5, i7 related to Haswell, Ivy Bridge?

Why do unstable nuclei form?

How to pronounce "r" after a "g"?

Was this a power play by Daenerys?

How do I get past a 3-year ban from overstay with VWP?



Splitting and extracting values from a row?


How to concatenate text from multiple rows into a single text string in SQL server?How do you split a list into evenly sized chunks?Extracting extension from filename in PythonHow do I sort a dictionary by value?How to access environment variable values?Use a list of values to select rows from a pandas dataframeDelete column from pandas DataFrame by column name“Large data” work flows using pandasHow to iterate over rows in a DataFrame in Pandas?Select rows from a DataFrame based on values in a column in pandas






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















From the following line, I want to extract the date and time including AM/PM.
But the time part of DateTime is skipped.



 6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On "

p=[]
xx = "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2
oil pump runing On "
new=re.split(r's',xx)
print(new)
p.append(new.pop(0))
p.append(new.pop(1))
print(p)









share|improve this question






























    0















    From the following line, I want to extract the date and time including AM/PM.
    But the time part of DateTime is skipped.



     6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On "

    p=[]
    xx = "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2
    oil pump runing On "
    new=re.split(r's',xx)
    print(new)
    p.append(new.pop(0))
    p.append(new.pop(1))
    print(p)









    share|improve this question


























      0












      0








      0








      From the following line, I want to extract the date and time including AM/PM.
      But the time part of DateTime is skipped.



       6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On "

      p=[]
      xx = "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2
      oil pump runing On "
      new=re.split(r's',xx)
      print(new)
      p.append(new.pop(0))
      p.append(new.pop(1))
      print(p)









      share|improve this question
















      From the following line, I want to extract the date and time including AM/PM.
      But the time part of DateTime is skipped.



       6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On "

      p=[]
      xx = "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2
      oil pump runing On "
      new=re.split(r's',xx)
      print(new)
      p.append(new.pop(0))
      p.append(new.pop(1))
      print(p)






      python pandas csv






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 23:23









      Anony-Mousse

      59.8k798164




      59.8k798164










      asked Mar 23 at 11:06









      imtiaz ul Hassanimtiaz ul Hassan

      417




      417






















          2 Answers
          2






          active

          oldest

          votes


















          1














          No, time part is there, pop function is the problem, your regex is fine, as can be seen by running source code below (there is no need for pop in this case tbh):



          Simple solution (without pop):



          import re

          xx = (
          "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On"
          )
          new = re.split(r"s", xx)
          print(new[:3])


          Which returns as expected:



          ['6/1/2018', '12:01:11.490', 'AM']


          Why it didn't work?



          When you pop element it is removed from the list. You remove 0 element ('6/1/2018'), new 0 element became the missing date and afterwards you popped first element which is actually AM.



          With popping you would do that to get all three (assumming new is already created as before):



          for _ in range(3):
          print(new.pop(0))





          share|improve this answer

























          • isn't there any other way I can retrieve those values without poping?

            – imtiaz ul Hassan
            Mar 23 at 11:37






          • 1





            Of course there is,updated my answer. It would work with pop as well, though it's totally not needed here IMO.

            – Szymon Maszke
            Mar 23 at 11:39



















          0














          I am not great at regex and there is certainly scope to tighten this regex up but as a first stab assuming your datetime strings have a fixed format. It does not validate the date.



          import re

          xx = "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On "

          p1 = re.compile('(?:d1,2/)2d4s+(?:d2:)2d2.d3s+[AaPp][Mm]')
          p = re.findall(p1, xx)
          print(p)





          share|improve this answer























          • You missed the actual problem with his code and created highly complex regex which does not work any better (only clutters the whole thing and makes it much less readable/understandable by others).

            – Szymon Maszke
            Mar 23 at 11:34












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          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%2fstackoverflow.com%2fquestions%2f55313044%2fsplitting-and-extracting-values-from-a-row%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          No, time part is there, pop function is the problem, your regex is fine, as can be seen by running source code below (there is no need for pop in this case tbh):



          Simple solution (without pop):



          import re

          xx = (
          "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On"
          )
          new = re.split(r"s", xx)
          print(new[:3])


          Which returns as expected:



          ['6/1/2018', '12:01:11.490', 'AM']


          Why it didn't work?



          When you pop element it is removed from the list. You remove 0 element ('6/1/2018'), new 0 element became the missing date and afterwards you popped first element which is actually AM.



          With popping you would do that to get all three (assumming new is already created as before):



          for _ in range(3):
          print(new.pop(0))





          share|improve this answer

























          • isn't there any other way I can retrieve those values without poping?

            – imtiaz ul Hassan
            Mar 23 at 11:37






          • 1





            Of course there is,updated my answer. It would work with pop as well, though it's totally not needed here IMO.

            – Szymon Maszke
            Mar 23 at 11:39
















          1














          No, time part is there, pop function is the problem, your regex is fine, as can be seen by running source code below (there is no need for pop in this case tbh):



          Simple solution (without pop):



          import re

          xx = (
          "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On"
          )
          new = re.split(r"s", xx)
          print(new[:3])


          Which returns as expected:



          ['6/1/2018', '12:01:11.490', 'AM']


          Why it didn't work?



          When you pop element it is removed from the list. You remove 0 element ('6/1/2018'), new 0 element became the missing date and afterwards you popped first element which is actually AM.



          With popping you would do that to get all three (assumming new is already created as before):



          for _ in range(3):
          print(new.pop(0))





          share|improve this answer

























          • isn't there any other way I can retrieve those values without poping?

            – imtiaz ul Hassan
            Mar 23 at 11:37






          • 1





            Of course there is,updated my answer. It would work with pop as well, though it's totally not needed here IMO.

            – Szymon Maszke
            Mar 23 at 11:39














          1












          1








          1







          No, time part is there, pop function is the problem, your regex is fine, as can be seen by running source code below (there is no need for pop in this case tbh):



          Simple solution (without pop):



          import re

          xx = (
          "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On"
          )
          new = re.split(r"s", xx)
          print(new[:3])


          Which returns as expected:



          ['6/1/2018', '12:01:11.490', 'AM']


          Why it didn't work?



          When you pop element it is removed from the list. You remove 0 element ('6/1/2018'), new 0 element became the missing date and afterwards you popped first element which is actually AM.



          With popping you would do that to get all three (assumming new is already created as before):



          for _ in range(3):
          print(new.pop(0))





          share|improve this answer















          No, time part is there, pop function is the problem, your regex is fine, as can be seen by running source code below (there is no need for pop in this case tbh):



          Simple solution (without pop):



          import re

          xx = (
          "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On"
          )
          new = re.split(r"s", xx)
          print(new[:3])


          Which returns as expected:



          ['6/1/2018', '12:01:11.490', 'AM']


          Why it didn't work?



          When you pop element it is removed from the list. You remove 0 element ('6/1/2018'), new 0 element became the missing date and afterwards you popped first element which is actually AM.



          With popping you would do that to get all three (assumming new is already created as before):



          for _ in range(3):
          print(new.pop(0))






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 23 at 11:38

























          answered Mar 23 at 11:32









          Szymon MaszkeSzymon Maszke

          3,1691729




          3,1691729












          • isn't there any other way I can retrieve those values without poping?

            – imtiaz ul Hassan
            Mar 23 at 11:37






          • 1





            Of course there is,updated my answer. It would work with pop as well, though it's totally not needed here IMO.

            – Szymon Maszke
            Mar 23 at 11:39


















          • isn't there any other way I can retrieve those values without poping?

            – imtiaz ul Hassan
            Mar 23 at 11:37






          • 1





            Of course there is,updated my answer. It would work with pop as well, though it's totally not needed here IMO.

            – Szymon Maszke
            Mar 23 at 11:39

















          isn't there any other way I can retrieve those values without poping?

          – imtiaz ul Hassan
          Mar 23 at 11:37





          isn't there any other way I can retrieve those values without poping?

          – imtiaz ul Hassan
          Mar 23 at 11:37




          1




          1





          Of course there is,updated my answer. It would work with pop as well, though it's totally not needed here IMO.

          – Szymon Maszke
          Mar 23 at 11:39






          Of course there is,updated my answer. It would work with pop as well, though it's totally not needed here IMO.

          – Szymon Maszke
          Mar 23 at 11:39














          0














          I am not great at regex and there is certainly scope to tighten this regex up but as a first stab assuming your datetime strings have a fixed format. It does not validate the date.



          import re

          xx = "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On "

          p1 = re.compile('(?:d1,2/)2d4s+(?:d2:)2d2.d3s+[AaPp][Mm]')
          p = re.findall(p1, xx)
          print(p)





          share|improve this answer























          • You missed the actual problem with his code and created highly complex regex which does not work any better (only clutters the whole thing and makes it much less readable/understandable by others).

            – Szymon Maszke
            Mar 23 at 11:34
















          0














          I am not great at regex and there is certainly scope to tighten this regex up but as a first stab assuming your datetime strings have a fixed format. It does not validate the date.



          import re

          xx = "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On "

          p1 = re.compile('(?:d1,2/)2d4s+(?:d2:)2d2.d3s+[AaPp][Mm]')
          p = re.findall(p1, xx)
          print(p)





          share|improve this answer























          • You missed the actual problem with his code and created highly complex regex which does not work any better (only clutters the whole thing and makes it much less readable/understandable by others).

            – Szymon Maszke
            Mar 23 at 11:34














          0












          0








          0







          I am not great at regex and there is certainly scope to tighten this regex up but as a first stab assuming your datetime strings have a fixed format. It does not validate the date.



          import re

          xx = "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On "

          p1 = re.compile('(?:d1,2/)2d4s+(?:d2:)2d2.d3s+[AaPp][Mm]')
          p = re.findall(p1, xx)
          print(p)





          share|improve this answer













          I am not great at regex and there is certainly scope to tighten this regex up but as a first stab assuming your datetime strings have a fixed format. It does not validate the date.



          import re

          xx = "6/1/2018 12:01:11.490 AM HEP.U02.OIL.GOV.P2_RUN <Unit #2>No.2 oil pump runing On "

          p1 = re.compile('(?:d1,2/)2d4s+(?:d2:)2d2.d3s+[AaPp][Mm]')
          p = re.findall(p1, xx)
          print(p)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 11:28









          QHarrQHarr

          41.7k82447




          41.7k82447












          • You missed the actual problem with his code and created highly complex regex which does not work any better (only clutters the whole thing and makes it much less readable/understandable by others).

            – Szymon Maszke
            Mar 23 at 11:34


















          • You missed the actual problem with his code and created highly complex regex which does not work any better (only clutters the whole thing and makes it much less readable/understandable by others).

            – Szymon Maszke
            Mar 23 at 11:34

















          You missed the actual problem with his code and created highly complex regex which does not work any better (only clutters the whole thing and makes it much less readable/understandable by others).

          – Szymon Maszke
          Mar 23 at 11:34






          You missed the actual problem with his code and created highly complex regex which does not work any better (only clutters the whole thing and makes it much less readable/understandable by others).

          – Szymon Maszke
          Mar 23 at 11:34


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f55313044%2fsplitting-and-extracting-values-from-a-row%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현