Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8563039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:52:05+00:00 2026-06-11T16:52:05+00:00

I have a .txt data where columns 6 and 7 are GPS position in

  • 0

I have a .txt data where columns 6 and 7 are GPS position in the form:

50;18.5701400N,4;07.7693770E

When I read it by read_csv I try to convert it to cartesian coordinates by using converters. I wrote the function for converter

convertFunc = lambda x : float((x[0:5]+x[6:12]).replace(';','.'))
convert = {6:convertFunc,7:convertFunc}

when I use it on single value it works how I would like:

convertFunc(myData.Lat[1])
Out [159]:  55.187110250000003

when I try to use it in read_csv it does not work

myData = DataFrame(read_csv('~/data.txt', sep=',' names=['A', 'B', 'C', 'D', 'E', 'Lat', 'Long'],converters=convert))

I have an error:

...
convertFunc = lambda x : float((x[0:5] + x[6:12]).replace(';', '.'))
ValueError: invalid literal for float(): DGPS ongitu

I don’t know where do it wrong or what I misunderstand in converters?
Or maybe anyone knows good way (package) to work with GPS data in that form?

(I think it can be some problem with lambda When I want to apply my function to the column I have an error: TypeError: only length-1 arrays can be converted to Python scalars)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:52:07+00:00Added an answer on June 11, 2026 at 4:52 pm

    That converter is a bit hacky; might I recommend something more robust like this?

    def convert_dmds(s):
        deg, min = s[:-1].split(';')
        sign = 1 if s[-1] in 'NE' else -1
        return sign * (float(deg) + float(min) / 60.0)
    
    def convert_gps(s):
        lat, lon = s.split(',')
        return (convert_dmds(lat), convert_dmds(lon))
    

    Also, the error indicates that you are trying to convert something that is clearly not a GPS string — a header row, perhaps?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to read .txt with missing values using pandas.read_csv. My data is of
When I using the following code to read file: lines=file(data.txt).read().split(\n) I have the following
I have 2 CSV files: a.txt contains data and a_props.txt describes type of columns,
Possible Duplicate: Only read limited number of columns in R I have a data
I have a 'data.txt' file containing two columns and N rows, corresponding to N
I have data stored in comma delimited txt files. One of the columns represents
I have the file data.txt with two columns and N rows, something like this:
I have data table containing one column as FilePath. FilePath D:\New folder\link.txt D:\New folder\SharepointMigration(Work
i have a .txt file containing data like: He: 22.1 Ar: 21.1 K: 1.22
I have 30 txt files with data And I want to create on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.