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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:02:25+00:00 2026-06-03T10:02:25+00:00

I have imported a file containing 8 columns, each column separated by ‘\t’ ,

  • 0

I have imported a file containing 8 columns, each column separated by '\t', so during import all '\t' are replaced by 'space' and '\n' are split to make indexing easier for me. Then a list is generated form input file for further analysis. But after analysis I got

lst =  ['PAIR', '1MFK', 'URANIUM', '82', 'HELIUM', '112', 3.6997']

kind of list, so I put

final = '    '.join(lst)   

to get the values like PAIR 1MFK 1 URANIUM 82 HELIUM 112 3.6997
But when I print all values it comes as following

PAIR 1MFK 1 URANIUM 82 HELIUM 112 3.6997  
PAIR 2JGH 2 PLUTONIUM 98 POTASSIUM 88 5.3003  
PAIR 345G 3 SODIUM 23 CARBON 14 1.664  
PAIR 4IG5 4 LITHIUM 82 ARGON 99 2.5506 

here the column entries don’t lie just one below another however indentation is same for all.

I have tried with '\t' but that produce same randomized result.
please help.

  • 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-03T10:02:30+00:00Added an answer on June 3, 2026 at 10:02 am

    If I understand you correctly, you can do something simple like this..

    >>> s = '''PAIR 1MFK 1 URANIUM 82 HELIUM 112 3.6997  
    ... PAIR 2JGH 2 PLUTONIUM 98 POTASSIUM 88 5.3003  
    ... PAIR 345G 3 SODIUM 23 CARBON 14 1.664  
    ... PAIR 4IG5 4 LITHIUM 82 ARGON 99 2.5506'''
    >>> ll = [x.split() for x in s.split('\n')]
    >>> for row in ll:
    ...   print ''.join(x.ljust(10) for x in row)
    ... 
    PAIR      1MFK      1         URANIUM   82        HELIUM    112       3.6997    
    PAIR      2JGH      2         PLUTONIUM 98        POTASSIUM 88        5.3003    
    PAIR      345G      3         SODIUM    23        CARBON    14        1.664     
    PAIR      4IG5      4         LITHIUM   82        ARGON     99        2.5506    
    

    Here I am using a fixed column width of 10 characters. If you like, you can make it slightly more sophisticated by calculating appropriate column widths beforehand.

    >>> column_widths = [max(len(x) for x in l) for l in zip(*ll)]
    >>> for row in ll:
    ...   print '  '.join(x.ljust(w) for x,w in zip(row, column_widths))
    ... 
    PAIR  1MFK  1  URANIUM    82  HELIUM     112  3.6997
    PAIR  2JGH  2  PLUTONIUM  98  POTASSIUM  88   5.3003
    PAIR  345G  3  SODIUM     23  CARBON     14   1.664 
    PAIR  4IG5  4  LITHIUM    82  ARGON      99   2.5506
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At first i have imported #import GDataXMLNode.h in .h file. Now this is my
I have imported a local directory in my svn repository using import /my/home/dir file://my/home/svn/repo/trunk
I have imported a csv file containing spatial area information in varchar, then converted
I have imported a file using the below command code='IN' exec import %s_tmp_file %
I have my CSV file imported as such: records = FasterCSV.read(path, :headers => true,
I have a table that was imported as all UPPER CASE and I would
I have an Excel file containing data(list of Phone numbers), and i want that
I have imported a certificate into a private ~/.keystore file: keytool -list Enter keystore
I have two .csv files containing correlation matrices exported from R. One file contains
I have an ASCII file containing a number of surfaces created in a seismic

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.