Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Read/Update flat files

Read/Update flat files

Scheduled Pinned Locked Moved C#
tutorialannouncement
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krrish
    wrote on last edited by
    #1

    Hi, i have two files one in .txt format and other in .xls format, i have matching set of data in both the files, my requirement is to compare and check the accuracy of the records whether both reflect the same set of data, based on the comparision result the corresponding records needs to be flagged, in both the files for each record compared. can any one guide me how to approach to acheive this. Note: Files needs to be read/updated at one shot Thanks in advance Krishna

    L 1 Reply Last reply
    0
    • K Krrish

      Hi, i have two files one in .txt format and other in .xls format, i have matching set of data in both the files, my requirement is to compare and check the accuracy of the records whether both reflect the same set of data, based on the comparision result the corresponding records needs to be flagged, in both the files for each record compared. can any one guide me how to approach to acheive this. Note: Files needs to be read/updated at one shot Thanks in advance Krishna

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Krrish wrote:

      at one shot

      What does that mean "specifically"? It is not a technical term.

      Krrish wrote:

      based on the comparision result the corresponding records needs to be flagged, in both the files for each record compared.

      flaged how? based on what results? You should just post your homework assignment since you are not very good at paraphrasing it.

      "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
      Colin Angus Mackay in the C# forum

      led mike

      K 1 Reply Last reply
      0
      • L led mike

        Krrish wrote:

        at one shot

        What does that mean "specifically"? It is not a technical term.

        Krrish wrote:

        based on the comparision result the corresponding records needs to be flagged, in both the files for each record compared.

        flaged how? based on what results? You should just post your homework assignment since you are not very good at paraphrasing it.

        "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
        Colin Angus Mackay in the C# forum

        led mike

        K Offline
        K Offline
        Krrish
        wrote on last edited by
        #3

        1)at one shot *What does that mean "specifically"? It is not a technical term. I mean the same function shoulad cater the requirement for both reading and updating the records 2)based on the comparision result the corresponding records needs to be flagged, in both the files for each record compared. *flaged how? based on what results? You should just post your homework assignment since you are not very good at paraphrasing it. as i have mentioned i have 2 files containing matching records, i try to compare the accuracy of the set of records, when a record is matched i have a column "Matched" within the record, and i want to update that column based on comparision result, ex: if a record in both files matches i update the column value as matched, otherwise as not-matched in both the .txt and .xls files Krishna

        L 1 Reply Last reply
        0
        • K Krrish

          1)at one shot *What does that mean "specifically"? It is not a technical term. I mean the same function shoulad cater the requirement for both reading and updating the records 2)based on the comparision result the corresponding records needs to be flagged, in both the files for each record compared. *flaged how? based on what results? You should just post your homework assignment since you are not very good at paraphrasing it. as i have mentioned i have 2 files containing matching records, i try to compare the accuracy of the set of records, when a record is matched i have a column "Matched" within the record, and i want to update that column based on comparision result, ex: if a record in both files matches i update the column value as matched, otherwise as not-matched in both the .txt and .xls files Krishna

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Krrish wrote:

          I mean the same function shoulad cater the requirement for both reading and updating the records

          Ok well that is a really bad design but it's your project I guess.

          Krrish wrote:

          i want to update that column based on comparision result,

          If the character width of the column is not going to change then you can just set the "file position" and then overwrite the column data with the new bytes. If the data width is going to change then it is much more complex because you have to write the entire file from the first position that changes the data width.

          "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
          Colin Angus Mackay in the C# forum

          led mike

          K 1 Reply Last reply
          0
          • L led mike

            Krrish wrote:

            I mean the same function shoulad cater the requirement for both reading and updating the records

            Ok well that is a really bad design but it's your project I guess.

            Krrish wrote:

            i want to update that column based on comparision result,

            If the character width of the column is not going to change then you can just set the "file position" and then overwrite the column data with the new bytes. If the data width is going to change then it is much more complex because you have to write the entire file from the first position that changes the data width.

            "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
            Colin Angus Mackay in the C# forum

            led mike

            K Offline
            K Offline
            Krrish
            wrote on last edited by
            #5

            is there any way that i can do sql operations to update the content, am able to get the whole content by querying string sqlstring = "SELECT * FROM temp.txt"; string sConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Shared\ExportAndDisplayData\;Extended Properties=Text;"; OleDbConnection objConn = new OleDbConnection(sConnectionString); objConn.Open(); OleDbCommand objCmdSelect = new OleDbCommand(sqlstring, objConn); objAdapter1.SelectCommand = objCmdSelect; DataSet objDataset1 = new DataSet(); objAdapter1.Fill(objDataset1, "Test"); DataTable dt1 = objDataset1.Tables[0]; Thanks in advance Krishna

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups