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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:47:44+00:00 2026-06-17T21:47:44+00:00

I have the same question as asked here: Default value for empty integer fields

  • 0

I have the same question as asked here:

Default value for empty integer fields when importing CSV data in MySQL

I keep getting the warning “Incorrect Integer value” when importing a csv file into Mysql. I’ve read all the relevant questions/answers here, and the link above is my direct question. But I’m trying to implement the answer given there in Python 2.7, and I can’t seem to get it working.

My code below is my attempt to implement the answer from the above post. I think the issue is the syntax for using the “Set” clause in my Load DATA Local Infile statement…I would really appreciate any help since MySQL automatically converts empty INT’s to “0” and that would mess up my analysis since I want blanks to be null. My code is:

import MySQLdb
db = MySQLdb.connect(blah, blah, blah)
cursor = db.cursor()

sql = """CREATE TABLE PLAYER(
       PLAYER_ID INT,
       DATE DATETIME,
       BATTING_AVERAGE INT
       )"""

cursor.execute(sql)
statement = """LOAD DATA LOCAL INFILE 'path/file.csv'
INTO TABLE PLAYER
COLUMNS TERMINATED BY ','
SET BATTING_AVERAGE = IF(@BATTING_AVERAGE='',NULL,@BATTING_AVERAGE)
IGNORE 1 LINES;"""

The error that this code gives is:

ProgramingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right synatx to use near ‘IGNORE 1 Lines at line 5”)

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

    The SET and IGNORE clauses are backwards. Try swapping them:

    statement = """LOAD DATA LOCAL INFILE 'path/file.csv'
    INTO TABLE PLAYER
    COLUMNS TERMINATED BY ','
    IGNORE 1 LINES
    SET BATTING_AVERAGE = IF(@BATTING_AVERAGE='',NULL,@BATTING_AVERAGE);"""
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a same question asked here(wasnt able to comment on it,maybe dont have
I have a issue with my java code. i asked the same question yesterday.
I have the same question problem as described here How to purge a cached
I have the same question as #1895500 , but with PostgreSQL not MySQL. How
Disclaimer: the same question has already been asked here Mapping deep properties with intermediate
I have same question asked in nServicebus group. I did not get firm answer
I guess this question that would have already been asked here. I searched but
This is the first question I have asked here so bear with me .
This same question was asked here and an answer was given which is workable,
I had the same question as asked here: New git repository in root directory

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.