Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading