CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2011
    Posts
    10

    Csv File Reading

    So my next task is to take a csv file with about 28 columns and parse the entire thing into a new file. Then I have a second csv file who has columns that overlap with the first one. These columns will not be parsed into the new csv file. The remaining columns in the second file will be parsed in though. So essentially I am merging the two files and only pulling the columns from the second one that don't exist in the first one. Can someone point me in the right direction on the best way to go about this? Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Csv File Reading

    Copy the second file, and edit the fields that you want, and delete the others.
    Or, just parse them both, but only use the fields that you want.

    You'd have to SPLIT() the text file into lines, then into fields, and then parse into a new record.

    Not really difficult, but might be more than a simple task
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Mar 2011
    Posts
    10

    Re: Csv File Reading

    That's a good idea about deleting the columns, but I think this has to be completed automated so it will be able to pull the files from their locations, perform the functions needed, and then probably upload them to the desired location. I'm not sure though. Do you have some links to any examples of splitting the contents of csv files btw? Thanks for the reply.

  4. #4
    Join Date
    Mar 2011
    Posts
    10

    Re: Csv File Reading

    Ok, I set it up so it iterates through all files in the folder and printed the contents of them into one large output file. I then deleted the columns I don't need from the second file. My next step is to set it up so it references the customer id column in the output file and matches it to the corresponding row in the second file and then add the columns for that row into the output file.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured