Sage 100

 View Only
  • 1.  VI challenge - merging two external files

    Posted 11-22-2024 15:09

    I have two files that I want to bring into Sage 100 with VI.  The first file has a list of Journal Entry numbers (about 40 to 50) that will be used to create tags in the InstaDocs Tag file. The second file has only one line of data and that is the data that needs to be put into every one of the records created from the first file. 

    I know that I could do some manipulation with Excel or some other editor, but I want this to be pretty automatic so that I can basically assign it to VI menu item or incorporate it into some other script for a non-sophisticated user to complete.

    I was thinking about a small script file that read the lines from the first file then added the data from the first file to each line then import the changed/appended file.  Alnoor suggested possibly using "perform logic" to read the second file and assign VI variables for use in the import.

    Has anyone ever done anything like this?  And if so, what was your solution?



    ------------------------------
    Chuck Peddy
    Smartbridge Partners
    ------------------------------


  • 2.  RE: VI challenge - merging two external files

    Posted 11-22-2024 21:58
    Edited by Wayne Schulz 11-22-2024 21:58

    Chatgpt appears to have suggestions on how to do this. I have not tested this. Use at your own risk and if I've misinterpreted your desired outcome then please disregard. You can also pretty easily have Chatgpt handle the archiving of files after they've been used.

    You'd likely be able to instruct CHATGPT use your coding language of choice. I've asked it to use a batch file SOLELY out of ease of understanding on my part. I make no assertion that a batch file is the way to go or that what GPT kicked out wil run flawlessly. As they say - your mileage may vary...



    I fed this into ChatGPT:

    I have two text files. The first file has 10 records. The second file has one record and i want to append that one record to the end of each of the 10 records in the first file. The output can be a CSV file. Is there a way to do this with a batch file? If so, what would be the commands?

    Yes, you can use a Windows batch file to achieve this. The steps involve reading the records from the first file line by line and appending the single record from the second file to each line. Here's how you can do it:


    Explanation of the Script

    1. Variables:

      • file1 holds the path to the first file with 10 records.
      • file2 holds the path to the second file with one record.
      • output specifies the name of the output CSV file.
    2. Reading the Single Record:

      • The script reads the single line from file2 using a for /f loop and stores it in the singleRecord variable.
    3. Processing the First File:

      • A for /f loop iterates through each line in file1.
      • The script appends the value of singleRecord to each line and writes it to the output file.
    4. Output File:

      • The new combined records are written to output.csv.



    ------------------------------
    Wayne Schulz
    wayne@s-consult.com
    Schulz Consulting
    (860) 516-8990
    CT
    ------------------------------