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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:51:23+00:00 2026-05-21T15:51:23+00:00

My problem is I got following encoding error while copying data from csv files

  • 0

My problem is I got following encoding error while copying data from csv files into a database table.

psycopg2.DataError: invalid byte sequence for encoding “UTF8”: 0xf8
HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by “client_encoding”.

I am not using any encoding and decoding command. And in order to copy data from file to a table I am using following code.

cur.copy_from(myFile, myTable)

And these files contains lot of special characters and wierd data. But I want to store all these data.

EDIT

The table is :

create table myTable(id integer, name character varying(10000));

and the sample of csv file is:

 "1";"This is  |_|¨^~~ || ¨text wuth special charater like Bjш;; ø"
 "2";"Test data  -._.- (2010/10/11) "
  • 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-21T15:51:23+00:00Added an answer on May 21, 2026 at 3:51 pm

    You write that you are not specifying any encoding, and it seems like psycopg2 defaults to UTF-8 then. 0xf8 isn’t a valid single-byte UTF-8 code point.

    Is your source file possibly in ISO-8859-1 where 0xf8 corresponds to ø?

    Edit:

    There are several places where this problem could be addressed, and which of them is correct depends on your situation.

    • If you repeatedly will have to import ISO-8859-1-files you might want to work with encoding to make your script consistent.

    • If you only need to do this import once, why not simply convert the files to the expected format outside of Python, with for example iconv or recode?

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

Sidebar

Related Questions

I've got the following problem: I need to write a decorator that would be
I got the following css: div#header, header { height: 88px; width: 100%; background-image: url('/images/header.jpg');
I've got the following situation, Private Sub MyButton_Click(sender as Object, args as EventArgs) Handles
I've got the following code: <?php echo strip_tags($firstArticle->introtext); ?> Where $firstArticle is a stdClass
I've got the following javascript function: function addConfirmLine(number, strItem, strValue) { var confirmLine =
So I've got the following HTML code: <object classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0><param name=quality value=high /><param name=movie
I have got an existing Rails project (Rails 2.3.8) and I got following Model
I got the following exception: System.Workflow.Runtime.Hosting.PersistenceException: Type ‘Microsoft.SharePoint.SPWeb’ in Assembly ‘Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’
I've got the following setup: public class SomeClass { private DirectoryEntry _root; private DirectorySearcher
I've got the following.. <ComboBox Grid.Row=2 Grid.Column=2 Grid.RowSpan=2 ItemsSource={Binding ShipperAddresses} Text={Binding ShipperAddress} Margin=85,2,0,2> <ComboBox.ItemTemplate>

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.