CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Filter a txt file based on an Excel template

  1. #1
    Join Date
    Feb 2020
    Posts
    30

    Filter a txt file based on an Excel template

    I have a text file composed of n records each of which consists of six numbers separated by a space, I need to filter this file to generate a new file that contains only the records that satisfy a specific condition set through a template made in excel .

    Each line of the file to be filtered must comply with a condition that is :
    the total of numbers present in each group as set in row 44 (I44, L44, O 44, R44 .... BE44) must satisfy a minimum and a maximum of presence as well as specified in BB7 / BC7 for the specific record analyzed to be validated.

    For example, the record reported as test (3 30 47 67 68 89) highlights a string of attendances equal to 0 0 0 1 0 4 3 3 3 3 1 0 0 (groups in which there are no numbers are not considered) which to the conditional string of line 44 it confirms the presence of a min of 4 and a max of 4 conditions met (see the 4 green stripes placed in correspondence with the occurrences that represent compliance with the condition).

    While for example the record 3 8 10 47 48 84 will be discarded and therefore not present in the Outputfile.txt file as it satisfies only 3 conditions instead of the minimum 4 provided.

    The file provided as an example 'ToPurgeFile.txt' consists of 6545 records and theoretically should be reduced by more than 50% with the excel template attached.

    link to download the sample files (data and template ) : https://we.tl/t-uVQesKTnDR

    thanks

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,844

    Re: Filter a txt file based on an Excel template

    And what is your problem? Your question?
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2020
    Posts
    30

    Re: Filter a txt file based on an Excel template

    right

    as I can't write the code, my knowledge is too poor, I ask if someone can write it for me

    thanks for the right observation

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,844

    Re: Filter a txt file based on an Excel template

    Quote Originally Posted by RIC63 View Post
    ...
    as I can't write the code, my knowledge is too poor, I ask if someone can write it for me
    ...
    It is not a good idea.
    If your knowledge is too poor, then try to improve it! So learn the C/C++ programming!
    Victor Nijegorodov

  5. #5
    Join Date
    Feb 2020
    Posts
    30

    Re: Filter a txt file based on an Excel template

    Hi VictorN

    in the past there was someone to whom I explained a similar problem and he kindly wrote me 20 lines of code, I'm not here to ask others to work for me and with a spirit of altruism everyone - if he wants - makes available to others their knowledge ... in this way everyone has the opportunity to learn something more .. with your approach no.
    If my request disturbs you, feel free to cancel my request

    with respect

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,399

    Re: Filter a txt file based on an Excel template

    With respect but it seems a lot like homework.

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,319

    Re: Filter a txt file based on an Excel template

    It's not homework. In a previous thread (https://forums.codeguru.com/showthre...t=#post2237550) I converted some Excel VBA code to C++ to speed up processing files.

    I've PM'd him indicating I might have time to do this in the next few days. But if any other guru can help, please do.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.8.2)

  8. #8
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,319

    Re: Filter a txt file based on an Excel template

    Quote Originally Posted by RIC63 View Post
    I have a text file composed of n records each of which consists of six numbers separated by a space, I need to filter this file to generate a new file that contains only the records that satisfy a specific condition set through a template made in excel .

    Each line of the file to be filtered must comply with a condition that is :
    the total of numbers present in each group as set in row 44 (I44, L44, O 44, R44 .... BE44) must satisfy a minimum and a maximum of presence as well as specified in BB7 / BC7 for the specific record analyzed to be validated.

    For example, the record reported as test (3 30 47 67 68 89) highlights a string of attendances equal to 0 0 0 1 0 4 3 3 3 3 1 0 0 (groups in which there are no numbers are not considered) which to the conditional string of line 44 it confirms the presence of a min of 4 and a max of 4 conditions met (see the 4 green stripes placed in correspondence with the occurrences that represent compliance with the condition).

    While for example the record 3 8 10 47 48 84 will be discarded and therefore not present in the Outputfile.txt file as it satisfies only 3 conditions instead of the minimum 4 provided.

    The file provided as an example 'ToPurgeFile.txt' consists of 6545 records and theoretically should be reduced by more than 50% with the excel template attached.

    link to download the sample files (data and template ) : https://we.tl/t-uVQesKTnDR

    thanks
    I've now had a look at this. Sorry, but I don't understand the requirement. If you're unable to provide working VBA code for conversion to C++ as previously, you're going to have to be much more specific without using specific terminology - and possibly provide a worked example of how you would filter manually (using pen/paper) given the spreadsheet and sample input file lines.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.8.2)

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)