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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:50:08+00:00 2026-06-18T09:50:08+00:00

I had some data in excel file. I changed the file to .csv file

  • 0

I had some data in excel file. I changed the file to .csv file and tried to write some python code to read the file.

But I am getting some unpredictable outputs. My Code is like this:

INPUT_DIR = os.path.join(os.getcwd(),"Input")
OUTPUT_DIR = os.path.join(os.getcwd(),"Output")
print INPUT_DIR, OUTPUT_DIR 

def read_csv():    
    files = os.listdir(INPUT_DIR)
    for file in files:
        file_full_name = os.path.join(INPUT_DIR,file)
        print file_full_name
        f = open(file_full_name,'r')
        for line in f.readlines():
            print "Line: ", line

def create_sql_file():
    print "Hi"


if __name__ == '__main__':
    read_csv()
    create_sql_file()

This gives very peculiar output:

 C:\calcWorkspace\13.1.1.0\PythonTest\src\Input C:\calcWorkspace\13.1.1.0\PythonTest\src\Output
C:\calcWorkspace\13.1.1.0\PythonTest\src\Input\Country Risk System Priority Data_01232013 - Copy.csv
Line:  PK**

Does someone know of this issue?

  • 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-18T09:50:09+00:00Added an answer on June 18, 2026 at 9:50 am

    First, make sure you converted the file from Excel to csv, using the Save As menu from Excel. Simply changing the extension doesn’t work. The output you are seeing is data from Excel’s native format.

    Once you have converted the files, use the csv module:

    import csv
    
    for filename in os.listdir(INPUT_DIR):
       with open(os.path.join(INPUT_DIR,filename), dialect='excel-tab') as infile:
          reader = csv.reader(infile)
          for row in reader:
              print row
    

    If you want to read raw Excel files, use the xlrd module. Here is a sample that shows how to read Excel files.

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

Sidebar

Related Questions

I'm working on a C++ application to read some data from an Excel file.
I had to convert some code (which deals with building a VBO of data
I had some question on python, I am trying to write something, where after
I need to import some data from a excel file and a folder with
I had xml file which have some data .and I had navigation url tage
I have a live database that had some data deleted from it and I
I'm trying to insert some data in the location mysiteurl/_layouts/ 'cause I had to
I had some code that constructed an object: function gridObjConst(id, itemName, itemPrice, itemListPrice, width,
I had some experience of android but know almost nothing of GCC Makefile. Here
I had some code that ran commands through Runtime.getRuntime.exec(String) , and it worked on

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.