473,395 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to separate data into individual columns.

1
Hello,

I have a set of data that looks like this:

044717.50-690930.3 -0.236
....
....

I want to be able to separate the data into just
044717.50 and 690930.3, ignoring the -0.236.

I'm not really sure how to approach this problem as I am a beginner in Python usage.

If it is possible, can you guys help me started with a sample code? Thanks so much!
Oct 14 '10 #1
1 1785
bvdet
2,851 Expert Mod 2GB
That can easily be done like this:
Expand|Select|Wrap|Line Numbers
  1. >>> s = '044717.50-690930.3    -0.236\n'
  2. >>> values = [item.strip() for item in s.split('-')][:2]
  3. >>> values
  4. ['044717.50', '690930.3']
  5. >>> 
I am assuming the dash character will always be there to split the string into individual numbers. They are still strings, so you can type cast them to float if needed.
Expand|Select|Wrap|Line Numbers
  1. [float(item.strip()) for item in s.split('-')][:2]
Oct 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jennifer Smith | last post by:
I want to be able to display my recordset as follows: a e b f c g d h Instead of : a b c d
6
by: alederer | last post by:
Hallo! I have a table tstest(ts char(13) for bit data constraint a unique). This column is filled in a trigger with generate_unique(). In a application (CLI), I have the values of this...
1
by: Ann Marinas | last post by:
Hello, everyone! I was wondering about data grids the other day, and I've got a question about it...... Can you hide columns in your datagrid even if the datagrid is binded? Thanks!
0
by: earsypaul | last post by:
Hello, With MS SQL server we can bcp hexadecimal data into varbinary columns quite nicely. We're migrating some data to DB2 and trying to import to a "varchar for bit data" data type column....
0
by: =?Utf-8?B?SiBTdHJlZ2Vy?= | last post by:
I have a procedure to increase/decrease the size of the columns in a datagrid proportional to their original size. I want to capture the event if a user manually resizes a column, so I can reset my...
1
by: phasita | last post by:
I would like to separate data in text file. For example A 35 160 B 25 145 C 40 130 the first column is name of member,the second column is age and the last one is...
11
by: Haydee Zimmerman | last post by:
Hoping someone can help me. I have 2 Access tables with a one to many relationship. the 1 side table holds the billing information, the many table side holds the billing id and modifier#. Now I...
1
by: sqldba | last post by:
Hi , I have the below tables Table 1 with columns id int price char quantity int date date
2
by: Serenityquinn15 | last post by:
Hi! I have little trouble in my Program. I need to total all the amount in specific column.. comes from the data produced by the datagrid.. heres my code: Set rs11 = New Recordset...
2
by: ahd2008 | last post by:
Hi everybody, I have the table Sessions as shown below: Session ID Start Date End Date Location Seats AvailabeSeats
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.