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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:57:56+00:00 2026-05-13T06:57:56+00:00

I read from source.sql ( sql script ) file INSERT INTO `Tbl_abc` VALUES (1111,

  • 0

I read from source.sql ( sql script ) file

INSERT INTO `Tbl_abc` VALUES (1111, 2222, 'CLEMENT', 'taya', 'MME', 'Gérant', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 4688, 0, NULL, NULL, 'MAILLOT 01/02/09', 'MAILLOT 01/04/09', NULL, NULL);

And write to dest.sql With my list formated

I met the problem with encoding for example:

Gérant= G\xc3\xa9rant

WHAT I AM TRYING

def DataMigration(dest, source, tbl_name, return_data=True):
    '''      
    '''
    data = []
    for ln in codecs.open(source, 'r', "utf-8").xreadlines():
        replace1 = ln.replace("INSERT INTO `"+tbl_name+"` VALUES (", "")
        replace2 = replace1.replace(");", "")
        list_replace = replace2.split(',')        
        s = list_replace
        data.append(list_replace)

    if return_data == True:
        ouputdata = [d for d in data if d[1] == ' 0' and d[6]==' 0']
        return ouputdata
    if return_data == False:
        return data

I print
print DataMigration(‘dest.sql’, ‘.source.sql’, ‘Tbl_abc’, False)

OUTPUT

  [['1111', ' 2222', " 'CLEMENT'", " 'taya'", " 'MME'", " 'G\xc3\xa9rant'", ' NULL', ' NULL', ' NULL', ' NULL', ' NULL', ' NULL', ' NULL', ' 4688', ' 0', ' NULL', ' NULL', " 'MAILLOT 01/04/09'", " 'MAILLOT 01/04/09'", ' NULL', ' NULL']]


But My Ouput file still has the problem.Any Could help me ?
  • 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-13T06:57:56+00:00Added an answer on May 13, 2026 at 6:57 am

    Please use .encode("utf-8"), when you write to .sql file too.

    open the file

    fileObj = codecs.open( "someFile", "r", "utf-8" )
    

    lets say you read it

    data=fileOjb.read()
    

    … do something on data

    open("newfile","w").write(data.encode("utf-8"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string read from another source such as \b\bfoo\bx. In this case,
When I read source from open source projects I often find a comment line
I was writing a generic class to read RSS feed from various source and
I'm developing a custom contacts app. I read default Contacts app source from Github
I want to read a specific line from an html source code. Im storing
I am trying to read from a file and encrypt the data using AES
I want to do MERGE from a source to a Target where I insert
I read from Outlook Contacts my Contacts and then I add the Contact to
I read from some books that Phusion Passenger is the answer to easy Ruby
From what I've read from Herb Sutter and others you would think that volatile

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.