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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:32:11+00:00 2026-06-08T19:32:11+00:00

Alright, so I’m supposed to make a script that parses all the chat logs

  • 0

Alright, so I’m supposed to make a script that parses all the chat logs from irc channels, combine the ones that match names, and then sort the chat logs by date.

This is an example chat log:

    jul 29 19:20:53 <lol> lolfile3
    jul 31 19:20:53 <lol> lolfile3321
    aug 1 19:20:53 <lol> lolfile31324
    jul 30 19:20:53 <lol> lolfile32

I need to order them by the timestamp (jul 30 19:20:53) however I’ve been trying for hours on end but to no avail.

Here’s the code I already have (this is file merging, file writing and everything. The timestamp is the last thing I need to do!)

I couldn’t figure out how to add code to my question so I link you to pastebin:
http://pastebin.com/2VrSRZZr

Thank you so much if you could help me by posting code. Obviously I don’t expect to be spoonfed but some code would be nice.

  • 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-08T19:32:14+00:00Added an answer on June 8, 2026 at 7:32 pm

    I’m not entirely sure what the “” in your example is, so this may not be entirely correct, but it shows how to convert the timestamp strings to comparable objects. Hopefully this gets you on the right track.

    DateFormat dateFormat = new SimpleDateFormat("MMM dd yyyy")
    List<String> lines = readLines(); // use a function of your to read the lines
    List<LogEntry> entries = new LinkedList<LogEntry>();
    for ( String line : lines ) {
      int splitIndex = line.indexOf("<log>");
      String time = line.substring(0,splitIndex);
      Date date = dateFormat.parse(time);
      entries.add(new LogEntry(date,line.substring(splitIndex));
    }
    
    Collections.sort(entries);
    
    
    // create a class to hold the log contents and the timestamp
    
    class LogEntry implements Comparable<LogEntry> {
        private final Date time;
        private final String entry;
    
        public void compare(LogEntry other) {
           return time.compareTo(other.time);
        }
    }
    

    EDIT: I ran the code you created in pastebin and the output was

    Fri Jul 29 17:09:50 EDT 2011 <phl0w> tes
    Sun Jul 31 17:08:49 EDT 2011 <yyyy> alewrwae
    Sun Jul 31 17:09:50 EDT 2011 <phl0w> tes
    Sun Jul 31 17:10:49 EDT 2011 <Andy_> Speed
    Sun Jul 31 17:10:51 EDT 2011 <Andy_> lol Speed
    Sun Jul 31 17:11:51 EDT 2011 <xxxx> wrkjaer
    Sun Jul 31 19:20:50 EDT 2011 <phl0w> lolfile1
    Sun Jul 31 19:20:53 EDT 2011 <phl0w> lolfile3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so I'm supposed to do an assignment: Say you have chat logs sorted
Alright y'all. I am attempting to write a bit of code that places typographic
Alright so my question is, how can I make a program that basically executes
Alright so i need to open a .txt file that will be created in
Alright I created some custom classes for my project sourced from this tutorial ,
Alright, here I am again trying to write code from scratch and I can't
Alright, I'll try and make this brief as possible. I wanted to a UIToolbar
Alright so this is a bizarre cross platform thing that I'm experiencing with text
Alright, I'm not the best with JOIN's and after all these years of working
Alright, so I've been trying to implement a simple binary search tree that uses

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.