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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:47:48+00:00 2026-06-05T21:47:48+00:00

How can I import a CSV file into a MySQL table? I would like

  • 0

How can I import a CSV file into a MySQL table? I would like for the first row of data be used as the column names.

I read How do I import CSV file into a MySQL table?, but the only answer was to use a GUI and not a shell?

  • 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-05T21:47:50+00:00Added an answer on June 5, 2026 at 9:47 pm

    Instead of writing a script to pull in information from a CSV file, you can link MYSQL directly to it and upload the information using the following SQL syntax.

    To import an Excel file into MySQL, first export it as a CSV file. Remove the CSV headers from the generated CSV file along with empty data that Excel may have put at the end of the CSV file.

    You can then import it into a MySQL table by running:

    load data local infile 'uniq.csv' into table tblUniq fields terminated by ','
      enclosed by '"'
      lines terminated by '\n'
        (uniqName, uniqCity, uniqComments)
    

    as read on: Import CSV file directly into MySQL

    EDIT

    For your case, you’ll need to write an interpreter first, for finding the first row, and assigning them as column names.


    EDIT-2

    From MySQL docs on LOAD DATA syntax:

    The IGNORE number LINES option can be used to ignore lines at the
    start of the file. For example, you can use IGNORE 1 LINES to skip
    over an initial header line containing column names:

    LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test IGNORE 1 LINES;
    

    Therefore, you can use the following statement:

    LOAD DATA LOCAL INFILE 'uniq.csv'
    INTO TABLE tblUniq
    FIELDS TERMINATED BY ','
        ENCLOSED BY '"'
    LINES TERMINATED BY '\n'
    IGNORE 1 LINES
    (uniqName, uniqCity, uniqComments)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I import CSV file data into SQL Server 2000 table? I need
I'm struggling to get sqlldr to import a csv data file into my table,
I need to import the data form .csv file into the database table (MS
I have to import data from a CSV file into MySQL database using JSP/Servlet.
Is it possible to import csv data into mysql and automatically create the column
I am trying to import a CSV file into a MySQL database table. The
i would like to import csv file in mysql database. my query would be
A user can import data into our website from a file. The data normally
I am writing the following script up import a csv file into a mysql
I imported a table from a CSV file into MySQL using this query: LOAD

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.