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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:16:45+00:00 2026-06-17T00:16:45+00:00

I just have few queries regarding the CSV files. -All the values are equal

  • 0

I just have few queries regarding the CSV files.

-All the values are equal to Header.

For Ex:-

abc.csv file contain

RollNO,Name,Age
1,Abc,15
2,Def,18

some times what’s happening the file is coming like this

RollNO,Name,Age
1,Abc,15
2,Def,18,blabla,21

In this case the value are greater then the header. So how can i check this thing.

-Check Blank Header

aaa.csv

RollNO,Name,Age, ,Address

I have to check that there should be no blank in the header.

-Check that there is no special character in the header.

bbb.csv

Rol$lNO,Name,Age,Address

I have to check this thing also that the header should not contain the special character.

Thanks in Advance!!!

  • 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-17T00:16:46+00:00Added an answer on June 17, 2026 at 12:16 am
    import re    
    csvfile = open('abc.csv','r')
    csv = [line.split(',') for line in csvfile.readlines()]
    

    Problem #1: Check if a data row is longer than the header row:

    for i in csv[1:]:
        if len(i) > len(csv[0]):
            print("found a data row that is longer then the header row.")
    

    Problem #2: Check if there’s an empty header item:

    blank = re.compile(r'\s*')
    for i in csv[0]:
        if blank.match(i).end() == len(i):
            print("found an empty header item")
    

    Problem #3: Check if there’s any special characters in the header:

    charset = re.compile(r'\w*')
    for i in csv[0]:
        if charset.match(i).end() != len(i):
            print("found a header item that contains special characters.")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several database tables that just contain a single column and very few
I have a few questions about css media queries. I. Does both css files
We have couple of tables, most of our queries use just a few joins,
I just have a few questions about programmatically adding controls in aspx . After
I have just started programming and have made a few small applications in C
I have a few static pages that are just pure HTML, that we display
I have just started learning NHibernate. Over the past few months I have been
When i have a few content with work well. And if i just put
I've heard before that modules are just classes too. I have a few situations,
I have got a few tables which I am trying to join. I just

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.