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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:56:25+00:00 2026-05-18T03:56:25+00:00

In my code I have a query that looks like this: $load_query = LOAD

  • 0

In my code I have a query that looks like this:

$load_query = "LOAD DATA LOCAL INFILE '{$file}' INTO TABLE `{$table}`
      FIELDS TERMINATED BY ',' ENCLOSED BY '\"';";

Here is an example row included in the file that I am trying to load:

"MC318199","06160","1","P","00750","00000","TN598792","04/16/2009","91X"                 

You will notice that at the end of the example row there are quite a few spaces. These spaces all occur before the new line character “\n” that terminates the line. The problem is that these spaces get entered into the database.

How can I remove the additional spaces when running the LOAD DATA INFILE command? Is there a way to use RTRIM?

Edit

As ajreal suggested I had to re-prepare the file. After the file was prepared it was inserted into the database correctly. I modified the bash script found at: http://gabeanderson.com/2008/02/01/unixlinux-find-replace-in-multiple-files/ to accomplish this. The code is shown below:

#!/bin/bash 
for fl in *.txt; do
  mv $fl $fl.old
  sed 's/[ \t]*$//' $fl.old > $fl
  rm -f $fl.old
done
  • 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-18T03:56:25+00:00Added an answer on May 18, 2026 at 3:56 am

    dun think too complicate, right after u loaded the data
    update $table set $last_column=rtrim($last_column);

    or manually remove the space in the $file using vi (or any editor)

    or re-preapare the $file

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

Sidebar

Related Questions

I have a select query that currently produces the following results: Description Code Price
I have code that references a web service, and I'd like the address of
I have code like this: var newMsg = new Msg { Var1 = var1,
I am debugging some code and have encountered the following SQL query (simplified version):
I have the following Java 6 code: Query q = em.createNativeQuery( select T.* +
Put it another way: what code have you written that cannot fail. I'm interested
We’ve found that the unit tests we’ve written for our C#/C++ code have really
I have code similar to this filtering entries in an Array of Objects: var
I have a page that is taking 37 seconds to load. While it is
I have a csv file that has 3.5 million codes in it. I should

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.