PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 26, 2022

[FIXED] How to remove the date from time data when it is separated by a space?

 August 26, 2022     csv, python, spyder, time     No comments   

Issue

I have some data in a current .csv file that is space separated then ; separated. I get how to do the sep";" but the problem is the spaces. It looks a little like this:

Time; Age; etc
04-09-2003 17:06:39 ; 29 ; etc

I need to get the date removed so that in "Time" there is only the variable of time (ie. I don't need the system to look at the date at all as it is rather irrelevant).

How would I go about this? And is it reproducible for around 5000 bits of data?

Many thanks in advance!


Solution

after seperating the line with ';', just split each part again after each ' '.

datetime = "04-09-2003 17:06:39"
parts = datetime.split(' ')
print(parts[1])


Answered By - Cruik
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing