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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:16:09+00:00 2026-06-13T00:16:09+00:00

I have file which contains the following data: ——————-[ server10 ]——————- user1 user2 user99

  • 0

I have file which contains the following data:

-------------------[ server10 ]-------------------
user1
user2
user99
user100
-------------------[ server20 ]-------------------
user1
user2
user10
user4
-------------------[ server30 ]-------------------
user10
user30
user40

I want to convert this output into Excel sheet, so that I can present ti to my management. Any idea how can do that???

I want the output into the following format in the Excel sheet:

Hostname            users
server10            user1
                    user2
                    user99
                    user100
server20            user2
                    user10
                    user4 
...
...

Till here “David” helped me with Python (openpyxl). but here i have new column (Last Logon time) which i want to add in excel so here is the example.

    -------------------[ server10 ]-------------------
    user1
    never
    user2
    Oct 17, 2011
    user99
    Jan 01, 2007
    user100
    Feb 02, 2010
    -------------------[ server20 ]-------------------
    user1
    never
    user2
    never
    user10
    jul 17, 2001
    user4
    Dec 25, 1999
    -------------------[ server30 ]-------------------
    user10
    Aug 10, 2012
    user30
    never
    user40
    never

In excel it would be like.

 Hostname            users           Last logon
    server10            user1            never
                        user2            Oct 17, 2011
                        user99           ...
                        user100          ...
    server20            user2
                        user10
                        user4 
    ...
    ...

Notes: username could be different here i gave you example userX but it would be spatel, jim, eric etc…

  • 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-13T00:16:10+00:00Added an answer on June 13, 2026 at 12:16 am

    Another alternative is to use the openpyxl module in python:

    from openpyxl import Workbook
    import fileinput
    import re
    
    wb = Workbook()
    ws = wb.get_active_sheet()
    
    servercol = 0
    usercol = 1
    lastlogoncol = 2
    currentrow = 1
    
    # write column headers
    ws.cell(row=0, column=servercol).value = 'server'
    ws.cell(row=0, column=usercol).value = 'user'
    ws.cell(row=0, column=lastlogoncol).value = 'last logon'
    
    # process each line and copy to spreadsheet
    for line in fileinput.input("somedata.txt"):
        # user regex to extract server from line
        m = re.match("^[-\[\s]+(?P<server>server\d+)[-\]\s]+$", line)
        n = re.match("^\s+user\d+", line)
        # if server match then write to server column
        if(m):
            c = ws.cell(row = currentrow, column = servercol)
            c.value = m.group('server')
        # elif user match, then write to user column
        elif(n):
            c = ws.cell(row = currentrow, column = usercol)
            c.value = line
        # else write to last logon column
        else:
            c = ws.cell(row = currentrow, column = lastlogoncol)
            c.value = line
            currentrow = currentrow + 1
    
    wb.save('mydata.xlsx')
    

    Note: this is somewhat fragile, since it depends on the inline data always following a “user” record with a “last logon” record. If this pattern is not followed, then the process will fail. For example, if you had two consecutive user records, without a “last logon” record in-between.

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

Sidebar

Related Questions

I have a file which contains lines of data in the following format: a11
I have a txt file which contains data in the following format: X1 Y1
I have a JSON file which contains data like the following: {"posts": [ {
I have a file which contains data in the following format: filename.jpg,132,234,234,345,4555,23333,344,...,333 I have
I have a file template.txt which contains the following: Hello ${something} I would like
I have a large XML file which in the middle contains the following: <ArticleName>Article
I have a text file which contains data seperated by '|'. I need to
I have a large file which contains lots of data, and I'd like to
I have a text file which contains the following: NUM,123 FRUIT DRINK FOOD,BACON CAR
Hi I have a text file which contains some numerical data. Of that text

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.