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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:51:01+00:00 2026-05-20T04:51:01+00:00

I am importing a .csv file into MySQL and everything works fine, except the

  • 0

I am importing a .csv file into MySQL and everything works fine, except the line breaks that are in the file.

One of my .csv rows looks like this:

42,E-A-R™ Classic™ Earplugs,ear,images/ear/classic.jpg,5%,"Proven size, shape, and foam
3M's most popular earplug
Corded and uncorded in a variety of individual packs
NRR 29 dB / CSA Class AL",312-1201,,"E-A-R™ Classic™ Uncorded Earplugs, in Poly Bag",310-1001,,E-A-R™ Classic™ Uncorded Earplugs in Pillow Pack,311-1101,,"E-A-R™ Classic™ Corded Earplugs, in Poly Bag"

The sixth field over should break into a new line when called, but it doesn’t. When importing the .csv I select Lines terminated by \r. I have tried \n and auto but no luck.

Weird thing is, the field looks correct in the database with all of the appropriate breaks. If I manually go in to insert the line breaks in PHPmyadmin it prints correctly. Each field is set to UTF-8 as well.

Any ideas on this? Thanks.

edit: here is the MySQL statement

LOAD DATA LOCAL INFILE '/tmp/php89FC0F' REPLACE INTO TABLE `ohes_flyer_products`
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\r'
  • 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-20T04:51:02+00:00Added an answer on May 20, 2026 at 4:51 am

    maybe you could use fgetcsv to parse each csv line into an array and then dump that array into the database?

    something along the lines of

    $fd = fopen($csvfile, "r");
    while ($line = fgetcsv($fd))
    {
        $sql = sprintf("INSERT INTO tablename (...) VALUES ('%s', ...)", $line[0], ...);
        $res = mysql_query($sql);
    }
    

    note 1: code not ready for production, check SQL injections!

    note 2: please, use prepared statements as using them will speed the thing a lot (or make one multi-row insert statement).

    note 3: wrap all in a transaction.

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

Sidebar

Related Questions

I am importing approx 350,000 lines from a CSV file into MySQL using PHP
I'm importing some data from a CSV file, and numbers that are larger than
I am importing a 2.5gb csv file to a mysql table. My storage engine
When importing a CSV file into Excel, it only strips the double-quotes from the
I am importing a csv file into R using the sqldf -package. I have
I am having some problem in importing a .csv file into a sqlite table.
In my iPhone app, I am importing CSV file into SQlite database using CHCSV
When importing numbers from a csv file, I need to convert them to floats
Is it possible to import csv data into mysql and automatically create the column
I'm working on an SSIS package where I'm importing data from a CSV file

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.