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 9128179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:27:17+00:00 2026-06-17T07:27:17+00:00

Completely new to python i’m having problems finding this with version 2.4 I have

  • 0

Completely new to python i’m having problems finding this with version 2.4

I have a text file that contains 3 columns they are tab delimited by not a single tab, 9 tabs.
1000 line file
ex:

$1$sda4356:[sgb1_diska5.ldlbat44.libabl]talild_0329_base.rpt                                talild_0329_base.rpt                                                                      00000000000000005062

What i need to do is sort everything by column 3 ( 00000000000000005062 ).

Is using the csv reader the best way to handle doing this? how do i get it to handle the fact that my text file is using 9 tabs to seperate each column. Most other things i’m finding are incompatiable with python 2.4.

  • 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-17T07:27:19+00:00Added an answer on June 17, 2026 at 7:27 am

    Since you’re using 9 tabs, str.split seems like it should be able to handle this properly, (but I don’t see any reason why csv would choke on it …):

    fobj = open('data.csv')
    data = [ x.split() for x in fobj ]
    fobj.close()  #don't forget to close :)
    

    Or possibly:

    delim = '\t'*9
    data = [ x.split(delim) for x in fobj ]
    

    Then you can sort that. In a newer version of python, you’d do:

    from operator import itemgetter
    data.sort(key=itemgetter(2))
    

    Try this first! (According to the comments and the documentation, key is supported in python2.4, but not python2.3). operator.itemgetter is also “new in python2.4” and itemgetter(2) is equivalent to lambda x:x[2] or the more verbose:

    def get2(x):
        return x[2]
    

    But I think you might need to rely on cmp for compatability with really old python versions (Note, that python3 no longer supports cmp):

    def compare(x1,x2):
        if x1[2] > x2[2]:
           return 1
        elif x1[2] < x2[2]:
           return -1
        else:
           return 0
    

    and then you’d sort:

    data.sort(cmp=compare)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I'm completely new to this. I created a python script that imports tkinter
I am completely new to Python and wanted to try this code from the
I am completely new to python. I have installed it on windows. I am
I am completely new to python and I have a serious problem which I
Apologies, I am completely new to Django and Python. I have 2 questions. First,
I'm new to Python so I may be going about this completely wrong, but
I am completely new to python but I found a package that I need
I have worked with ASP.NET(C#, classic/MVC), Django(Python) and CI(php) but I am completely new
I'm new to python and have been trying to figure this out all day.
I am completely new to Python and wanted to use py2neo and tornado module.

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.