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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:11:02+00:00 2026-06-12T23:11:02+00:00

I am parsing a flat file which is working line by line and inserting

  • 0

I am parsing a flat file which is working line by line and inserting into the database but I want to add an additional step, actually additional 2 steps.

First I only want records for recalls for specific car manufacturers which I have a database table called AutoMake that has a list of all the makes I want to include. I need to compare the record to that table to ensure that it is a record of one of the makes that I want to include.

Then I need to do a second check to make sure the record is not already in my database.
This is a console App and I am using Entity for this. So here is my code I am driving myself crazy trying to write and rewrite this to include the checks but im just not getting it.

Oh and not that it really matters because if someone can get me in the right direction I can move from there but tokens[2] is the MAKETXT and RCL_CMPT_ID is tokens[23] and RCL_CMPT_ID can be used to verify if a record is already in the database since it is a unique value

    public static void ParseTSV(string location)
    {
        Console.WriteLine("Parsing.....");

        using (var reader = new StreamReader(location))
        {
            var lines = reader.ReadToEnd().Split(new char[] { '\n' });

            if (lines.Length > 0)
            {
               foreach (string line in lines)
               {
                  if (string.IsNullOrWhiteSpace(line))
                  {
                    continue;
                  }
                  var tokens = line.Trim().Split(new char[] { '\t' });

                  var recalls = new Recalls();

                  recalls.RECORD_ID = tokens[0];
                  recalls.CAMPNO = tokens[1];
                  recalls.MAKETXT = tokens[2];
                  recalls.MODELTXT = tokens[3];
                  recalls.YEARTXT = tokens[4];
                  recalls.MFGCAMPNO = tokens[5];
                  recalls.COMPNAME = tokens[6];
                  recalls.MFGNAME = tokens[7];
                  recalls.BGMAN = tokens[8];
                  recalls.ENDMAN = tokens[9];
                  recalls.RCLTYPECD = tokens[10];
                  recalls.POTAFF = tokens[11];
                  recalls.ODATE = tokens[12];
                  recalls.INFLUENCED_BY = tokens[13];
                  recalls.MFGTXT = tokens[14];
                  recalls.RCDATE = tokens[15];
                  recalls.DATEA = tokens[16];
                  recalls.RPNO = tokens[17];
                  recalls.FMVSS = tokens[18];
                  recalls.DESC_DEFECT = tokens[19];
                  recalls.CONEQUENCE_DEFECT = tokens[20];
                  recalls.CORRECTIVE_ACTION = tokens[21];
                  recalls.NOTES = tokens[22];
                  recalls.RCL_CMPT_ID = tokens[23];


                  string connectionString = GetConnectionString();
                  using (SqlConnection connection = new SqlConnection(connectionString))
                  {
                      SqlCommand cmdIns = new SqlCommand(GetInsertSqlCust(recalls), connection);
                      connection.Open();
                      cmdIns.ExecuteNonQuery();
                      connection.Close();
                      cmdIns.Dispose();
                      cmdIns = null;
                  }
              }
          }
      }
  }
  • 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-12T23:11:03+00:00Added an answer on June 12, 2026 at 11:11 pm

    1:Get the ID to check against
    2:Get the table where the search needs to be done like

     string strExpression="";
        (Datatable tdGeneric = dal.getsometable())
    

    3:To check the auto make if exists:

    if ( tdGeneric != null && tdGeneric.Rows.Count > 0)
      {
       strExpression = "tablecolumnsname = '" + recalls.MAKETXT + "' ";
       tdGeneric.DefaultView.RowFilter = strExpression;
       tdGeneric = tdGeneric.DefaultView.ToTable();
        if (tdGeneric.Rows.Count > 0)
        {
              //make exist
        }
        else
         make don't exists
    
      }
      else
     {
       make don't exist skip that text file's record
     }
    

    4: if make exist then check for a record if that exists in a table.

    get the original table,search on that table for specific id in your case:

     (Datatable tdGeneric2 = dal.getsometable())
     if ( tdGeneric2 != null && tdGeneric.Rows.Count > 0)
          {
           strExpression = "tablecolumnsname = '" + recalls.RCL_CMPT_ID + "' ";
           tdGeneric2.DefaultView.RowFilter = strExpression;
           tdGeneric2 = tdGeneric2.DefaultView.ToTable();
              if (tdGeneric2.Rows.Count > 0)
            {
                  //record exist
            }
            else
             record don't exists
          }
          else
         {
           record don't exist insert the record, or some flag to insert a record
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem parsing a XML file which contains special characters like ,
I wrote a script parsing a .csv file in groovy using tokenize, which ended
i want to know which approach is better to saving Webpage content to database
Parsing some data and inserting it into 3 tables from .NET. Using Table Valued
I have a fixed-width flat file. To make matters worse, each line can either
I am using BeanIO to convert flat file into list of Object . Using
When parsing an xml file in android, I'm doing like this: try { InputStream
Not parsing the parameters in the beginning but parse the input string read from
I'm parsing a date from a JSON event feed - but the date shows
I need help in parsing big Json file: {status:{code:200,text:OK},content:[{proposalId:12536,providerId:1,supervisorName:null,supervisorEmail:lolbroek_13@hotmail.com,hostInstitution:qsd,hostCountry:qsd,hostCity:QSD,hostTypeId:1,title:qsd,status:available,numberStudents:null,description:qsd,categoryId:34,startDate:null,endDate:null,submitDate:null,expectedWorkload:null,purpose:null,workOrganisationId:1,function:null,audienceId:1,preConditions:,certificationGranted:null,deliverables:null,expenses:null,revenue:null,vacancies:null,uploadImg:http:\/\/193.136.60.238\/\/MUTW2012\/core\/img\/internship.png}, {proposalId:12537,providerId:1,supervisorName:null,supervisorEmail:lolbroek_13@hotmail.com,hostInstitution:qsd,hostCountry:qsd,hostCity:QSD,hostTypeId:1,title:qsd,status:available,numberStudents:null,description:qsd,categoryId:34,startDate:null,endDate:null,submitDate:null,expectedWorkload:null,purpose:null,workOrganisationId:1,function:null,audienceId:1,preConditions:,certificationGranted:null,deliverables:null,expenses:null,revenue:null,vacancies:null,uploadImg:http:\/\/193.136.60.238\/\/MUTW2012\/core\/img\/internship.png}, {proposalId:12538,providerId:1,supervisorName:null,supervisorEmail:lolbroek_13@hotmail.com,hostInstitution:qsd,hostCountry:qsd,hostCity:QSD,hostTypeId:1,title:qsd,status:available,numberStudents:null,description:qsd,categoryId:34,startDate:null,endDate:null,submitDate:null,expectedWorkload:null,purpose:null,workOrganisationId:1,function:null,audienceId:1,preConditions:,certificationGranted:null,deliverables:null,expenses:null,revenue:null,vacancies:null,uploadImg:http:\/\/193.136.60.238\/\/MUTW2012\/core\/img\/internship.png}, {proposalId:12539,providerId:1,supervisorName:null,supervisorEmail:lolbroek_13@hotmail.com,hostInstitution:qsd,hostCountry:qsd,hostCity:QSD,hostTypeId:1,title:qsd,status:available,numberStudents:null,description:qsd,categoryId:34,startDate:null,endDate:null,submitDate:null,expectedWorkload:null,purpose:null,workOrganisationId:1,function:null,audienceId:1,preConditions:,certificationGranted:null,deliverables:null,expenses:null,revenue:null,vacancies:null,uploadImg:http:\/\/193.136.60.238\/\/MUTW2012\/core\/img\/internship.png}, ................[etc] I

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.