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

  • Home
  • SEARCH
  • 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 7641651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:58:42+00:00 2026-05-31T08:58:42+00:00

I would like to convert specific ascii file to csv. This ascii file has

  • 0

I would like to convert specific ascii file to csv.
This ascii file has own specification and I post below relevant fragments.

line A starts with code 66TP:

66TP        1003    54.437269600149717.012388003107655.5139691177756                :10.008677993245250.01231534739191

line B starts with C6NM:

C6NM0821.565823793411260.900167346000671.2812114953994820.81007696688170033                                1679475490.0000000001679475527.0000000001

As you see above individual values are not separated but their differentiation is
by position and length in line.

spec of line A:

1 Position   Length Data format Description of field

2   1           2   Type code   Record type code = 66
3   3           2   Derivation  Derivation code
4   5           16  Name        Point name
5   21          16  Latitude    Latitude
6   37          16  Longitude   Longitude
7   53          16  Distance    WGS84 ellipsoidal height at APC
8   69          16  Text 16     Feature code
9   85          1   GPS Method  Measurement method
10  86          1   Classification  Classification of the point
11  87          16  Distance    Horizontal precision
12  103         16  Distance    Vertical precision

spec of line B:

1   Position Length Data format Description of field
2   1           2   Type code   Record type code = C6
3   3           2   Derivation  Derivation code
4   5           2   Integer 2   Minimum number of satellites
5   7           1   Boolean     Relative DOPs
6   8               16  Scalar  PDOP (maximum)
7   24          16  Scalar  HDOP (maximum)
8   40          16  Scalar  VDOP (maximum)
9   56          16  Scalar  RMS
10  72          4   Integer 4   Number of GPS positions used
11  76          16  Distance    Horizontal standard deviation
12  92          16  Distance    Vertical standard deviation
13  108         4   Integer 4   Start GPS week
14  112         16  Scalar  Start GPS time in seconds to 3dp
15  128         4   Integer 4   End GPS Week
16  132         16  Scalar  End GPS time in seconds to 3dp
17  148         1   Monitor Status

my desired output is to merge both lines and would be like:

1003,54.4372696001497,17.0123880031076,55.5139691177756,0.009,0.012,8,1.6,0.9,1.28,20.8,033,1679,475490.0,1679,475527.0

and here’s input file where I marked individual values with square brackets:

66TP        [1003]    [54.4372696001497][17.0123880031076][55.5139691177756]                :1[0.00867799324525][0.01231534739191]

C6NM[082][1.56582379341126][0.90016734600067][1.28121149539948][20.81007696688170][033]                                [1679][475490.000000000][1679][475527.0000000001]

Sorry for quite long post but I have no idea how could I describe it in shorter way.
I am an amateur beginner programmer and I’d like to ask you for any hint that let me start
handling such type of data.

  • 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-05-31T08:58:43+00:00Added an answer on May 31, 2026 at 8:58 am

    Since you know the position of each element on each line, use a string slice to grab each element.

    For example,

    type_code = linea[0:2]
    (derivation, name) = (linea[2:4], linea[4:20])
    

    To take this a step further, you could write a little function to split a line apart given a list of the lengths for the line.

    Code

    def split_string_by_position(a_string, lengths):
        result = []
        position = 0
        for length in lengths:
            result.append(a_string[position:position+length])
            position = position+length
        return result
    
    
    line = '66TP        1003    54.437269600149717.012388003107655.5139691177756'
    lengths = [2, 2, 16, 16, 16, 16, 16, 16, 1, 1, 16, 16]
    
    print(split_string_by_position(line, lengths))
    

    Output

    ['66', 'TP', '        1003    ', '54.4372696001497', '17.0123880031076', '55.5139691177756', '', '', '', '', '', '']
    

    This just returns a list of the data elements. You could takes this a step further by providing a variable name along with each length ([[2,'type'], [2,'derivation'],...]) and change the function around a little so it returns a dict instead so you could then access it by using the_result['variable_name']

    A few ideas to play with. http://learnpythonthehardway.org/ would be a good thing for you to work through so you learn the basics of the language.

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

Sidebar

Related Questions

I would like to convert a yyyy-mm-dd to something like this: Saturday, 2 October
I would like to convert this string foo_utf = u'nästy chäräctörs with å and
I would like to convert this fluent approach to xml: container.Register( AllTypes.FromAssemblyNamed(Company.DataAccess) .BasedOn(typeof(IReadDao<>)).WithService.FromInterface(), AllTypes.FromAssemblyNamed(Framework.DataAccess.NHibernateProvider)
I got the below code which I would like to convert to a string
I would like to convert a string into a node. I have a method
I would like to convert tab to spaces in gVim. I added the following
I would like to convert from an image (like jpg or png) to PDF.
I would like to convert BufferedImage to an image that will display on JSP
I would like to convert some value from a XML attribute into valid HTML
I would like to convert my Subversion repository to Mercurial. I have a pretty

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.