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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:21:33+00:00 2026-05-24T14:21:33+00:00

First, Let me apologize as I know NOTHING about ruby. I can read through

  • 0

First, Let me apologize as I know NOTHING about ruby. I can read through the code and understand whats going on, but have never written any code.

I have a script we use to parse some log files that we obtained from someone a long time ago.

# format the csv data into an sql insert query
def FormatToSQL(file_name)
  $logger.info(caller) { "creating SQL insert q's" }
  formatted_data = []
  data_lines = []
  open("#{LOCAL_DIR}/#{file_name}") { |f| data_lines = f.readlines }
  data_lines.each do |r|
    data = []
    rdata = r.split(' ')
    rdata.each { |e| data.push("'#{e}'") }
    data.unshift('DEFAULT')
    sql_data = data.join(',')
    formatted_data.push(sql_data)
  end
  return(formatted_data)
end
# -------------------------------------------------------------------
# -------------------------------------------------------------------
# M  A   I    N

$logger = Logger.new("//var/www/metaquery/calllogger.log", 3, 1024000)
$logger.info(caller) { "start" }
now = Time.now().gmtime() - 3600  ## files are name using UTC
file_name = sprintf("calllog_%s_%02d_%02d_%02d.log", now.year, now.month.to_i,     now.day.to_i, now.hour.to_i)
if(doSFTPPull(file_name)) then
  ConnectDB()
  formatted_sql = FormatToSQL(file_name)
  formatted_sql.each { |sql| $local_conn.query("insert into #{DB_TABLE} values(#{sql})") }
else
  # we did not download the new file, report to ???
  false
end
$logger.info(caller) { "normal end" }
# -------------------------------------------------------------------

The log contains thousands of rows of records, like so

2xx3xx2xx7 2xx3xx56xx 07/28/11.19:55:45 19:55:46 20:00:00 2 4092 - - N - - TER - A T -

However, we enabled some new QoS Stats, and it adds lines like this,

VQM: 2xx3xx00xx 08/12/11.13:02:07 - - - - 20ms 0 0

I want to add a statement to ignore anylines beginning with VQM, as this throws the column count off on the MySQL Inserts, ultimately causing the query to fail, thus causing the script to fail.

How would I acheive this? Again, sorry for being a complete Noob with Ruby. Im only a php guy, and not even good at that. lol

I do know, the area probably has to be in
data_lines.each do |r|

where the code would be, and likely a if/then with some regex. thanks for your 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-05-24T14:21:34+00:00Added an answer on May 24, 2026 at 2:21 pm

    Try something like:

    data_lines.each do |r|
      next if r.match(/^VQM/) #will skip this one if the line starts VQM
      #everything else as before
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me first apologize. I've been coding for a long time now, but I'm
Let me state first: I know that any user that wants to run a
First of all, let's define a few tables: Users table will store information about
First off let me say I am maintaining someone else's poorly designed code so
First of all let me know if my question is completely vague or doesnt
Caveats: Let me first clarify that this is not a question about whether to
First, let me apologize, I'm new at web development, so I'm not quite sure
First let me say that I really feel directionless on this question. I am
First, let's get the security considerations out of the way. I'm using simple authentication
Let's say the first N integers divisible by 3 starting with 9. I'm sure

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.