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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:08:32+00:00 2026-06-08T00:08:32+00:00

I am building an application which accepts csv data as an uploaded file. Here

  • 0

I am building an application which accepts csv data as an uploaded file.

Here is the relevent part of my view:

def climate_upload(request):
    ...
    reader = csv.reader(file, delimiter=';')    # news csv reader instance 
    next(reader)    # skip header row

    for line in reader:
        if not line:
            continue    
        report = site_name
        report.year = line[1]
        report.month = line[2]
        ...
        report.save()
    file.close()    # close file
    ...

So, this works fine on data which looks like this:

;"headers"
;2012;5;2012-06-01;27.1;24.5;29.8;26.8;85;0.8
;2012;5;2012-06-02;27.1;24.5;29.8;26.8;85;0.8

But fails on this:

"headers"
2012;5;2012-06-01;27.1;24.5;29.8;26.8;85;0.8
2012;5;2012-06-02;27.1;24.5;29.8;26.8;85;0.8

Note the lack of initial delimiter on each line.

Unfortunately MS Excel seems to spit out the second version. I assume that reader is not recognizing a new line as a delimiter. Is there some flag with reader which will force it to accept \n as a delimiter as well as ; ?

Any help much appreciated.

  • 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-08T00:08:33+00:00Added an answer on June 8, 2026 at 12:08 am

    The delimiters or newlines aren’t the problem – you’re counting incorrectly.

    The first element of a list has the index 0. So it should be

    report.year = line[0]
    report.month = line[1]
    # etc.
    

    I’m guessing you’re running into a List index out of range exception on the last element (line[9]).

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

Sidebar

Related Questions

I am building a Monotouch application which downloads data from the server encrypted using
I'm looking for some opinions here, I'm building a web application which has the
I am building a viewer application, which needs to accept any kind of file
I am building an application which works on data from column based database. I
I'm building an application which uses CDI (Weld Container) and @ConversationScope for the views.
I am building an application which stores GPS locations in a SQLite database and
I'm building an application which will be able to send emails at any specific
I'm building an MVC application which uses Windows Authentication. I want to handle a
i'm building an android application which have a chat. in this chat i each
I'm building a C# application which uses plug-ins. The application must guarantee to the

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.