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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:01:10+00:00 2026-05-11T07:01:10+00:00

Whenever I try to open a .csv file with the python command fread =

  • 0

Whenever I try to open a .csv file with the python command fread = open('input.csv', 'r') it always opens the file with spaces between every single character. I’m guessing it’s something wrong with the text file because I can open other text files with the same command and they are loaded correctly. Does anyone know why a text file would load like this in python?

Thanks.

Update

Ok, I got it with the help of Jarret Hardie’s post

this is the code that I used to convert the file to ascii

fread = open('input.csv', 'rb').read() mytext = fread.decode('utf-16') mytext = mytext.encode('ascii', 'ignore') fwrite = open('input-ascii.csv', 'wb') fwrite.write(mytext) 

Thanks!

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T07:01:11+00:00Added an answer on May 11, 2026 at 7:01 am

    The post by recursive is probably right… the contents of the file are likely encoded with a multi-byte charset. If this is, in fact, the case you can likely read the file in python itself without having to convert it first outside of python.

    Try something like:

    fread = open('input.csv', 'rb').read() mytext = fread.decode('utf-16') 

    The ‘b’ flag ensures the file is read as binary data. You’ll need to know (or guess) the original encoding… in this example, I’ve used utf-16, but YMMV. This will convert the file to unicode. If you truly have a file with multi-byte chars, I don’t recommend converting it to ascii as you may end up losing a lot of the characters in the process.

    EDIT: Thanks for uploading the file. There are two bytes at the front of the file which indicates that it does, indeed, use a wide charset. If you’re curious, open the file in a hex editor as some have suggested… you’ll see something in the text version like ‘I.D.|.’ (etc). The dot is the extra byte for each char.

    The code snippet above seems to work on my machine with that file.

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

Sidebar

Related Questions

Whenever I try to install a Click Once application, I always get a 404
Whenever i try to open my Entity Model, i get a not very helpful
We have an application using the IBM Informix driver. Whenever we try to open
Whenever I try to add a new project to my SourceSafe repository it creates
Whenever I try to write graphical programs (whether a game or really any GUI
whenever I try to run something in Java, Eclipse changes into the PHP perspective.
Whenever I try to copy an entire working copy using simple drag and drop
I get the above error whenever I try and use ActionLink ? I've only
Why in Windows, can't you name a folder 'con'? Whenever I try to name
Whenever I design a database, I always wonder if there is a best way

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.