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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:00:13+00:00 2026-05-14T03:00:13+00:00

I have a CSV file. The first row will always contain column headers. Depending

  • 0

I have a CSV file. The first row will always contain column headers. Depending on a variety of factors, the order of columns may change and, in rare circumstances, some columns may not be present. These changes are beyond my control.

My thoughts, so far, on how to address this. I’ll read the first row of the file and use the values to generate a list of columns contained in the source file. The destination file will use the same column names as the source. This should be as simple as searching for identical names in the source and destination, then just mapping the column index values, right?

What are your recommendations for handling this?

  • 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-14T03:00:14+00:00Added an answer on May 14, 2026 at 3:00 am

    I did this once by building a Hash Map of the names of the columns I expected to be there to the indexes (or actual column names) of the the column headers that were actually present. I did this by first building the map with all the column names I expected as keys and some value like -1 as the values. I then got the array of column headers. With a nested loop going through both the loop for all keys in the map and all headers present in the file, I did a case insensitive comparison after trimming out the whitespace, if there was a match I put the index of the column as the value for that key in the map. Then when building the destination file all I had to do was loop through the keys in the map for every line in the CSV and get the data from the index specified in the map and do whatever I want with the data, ignoring the column if the value in the map was -1. I did this in Java, but I imagine it is nearly exactly the same in C#.

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

Sidebar

Ask A Question

Stats

  • Questions 409k
  • Answers 409k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What you are doing is the equivalent of: struct A… May 15, 2026 at 7:15 am
  • Editorial Team
    Editorial Team added an answer The closest you'll get to that in the standard MySQL… May 15, 2026 at 7:15 am
  • Editorial Team
    Editorial Team added an answer Here is a sample project showing feeding a location into… May 15, 2026 at 7:15 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.