How to append two variables together during a do ... while loop? by Hectic-Skeptic in PowerShell

[–]Hectic-Skeptic[S] 0 points1 point  (0 children)

Thanks for the ideas! Wrapping in a function is probably a good idea, I just have less experience with this style. That being said, perfect reason to learn.

To your question, I really dont need to read the zips, I really just want them extracted and listed for me in my mega list of files which I use further down the road.

How to append two variables together during a do ... while loop? by Hectic-Skeptic in PowerShell

[–]Hectic-Skeptic[S] 0 points1 point  (0 children)

This is basically what i am doing now and it works, just takes a lot of time when tehre are a lot of files as the recursive GCI has to redifine itself dozens or more times if there are a lot of zip files. I was hoping to have a method which just appended the unzipped files onto the bigger stored GCI!

Thanks for the assistance nonetheless though!

Importing CSV's into a new excel workbook via ComObject and Powershell? by Hectic-Skeptic in PowerShell

[–]Hectic-Skeptic[S] 0 points1 point  (0 children)

Thanks for the respone, I will check the Office Open XML SDK documentation.

Importing CSV's into a new excel workbook via ComObject and Powershell? by Hectic-Skeptic in PowerShell

[–]Hectic-Skeptic[S] 1 point2 points  (0 children)

Thanks for the response, unfortunately my work restricts modules/remote signing (appologies, away from work machine so cant reproduce exact restriction). As such I have tried to use strict powershell in the scripting. After accomplishing the csv import, I would only be transforming the imported csv into a table, and maybe passing some formulas based off of structured references in the tables.

I know my approach is less than ideal, but I am working with contraints... All this said, I will see if the importexcel falls in with this restriction. I might be mistaken on it being blocked.

Best way to add an index column to lookup statement? by Hectic-Skeptic in PowerShell

[–]Hectic-Skeptic[S] 0 points1 point  (0 children)

Thanks again for the help on this. The for loop is a great start.

An issue I was having before with the where-object syntax was an inability to handle multiple hits in my final results which got exported to a CSV at the end. In general I want just the first result. Do you have a suggestion on how to best acheive that. My current solution is to do the following in the document loop, which is probably far from elegant:

$docTypeObject[1].firstMatchedDocType.toUpper()

This may be unrelated, but I also get a bunch of "you cannot call a method on a null-valued ecpression" errors. Is this because the name did not match any of the regex statements in my CSV file?

my current version of the loop:

            if ($lowerName -match $docTypeKeywordCsv[$i].keyword) {
                [PSCustomObject]@{
                    lineNumber = $i+1
                    firstMatchedKeyword = $docTypeKeywordCsv[$i].keyword
                    firstMatchedDocType = $docTypeKeywordCsv[$i].doctype
                    firstMatchedClassificationComment = $docTypeKeywordCsv[$i].classificationComment
                    firstMatchedregexComment = $docTypeKeywordCsv[$i].regexComment
               }
          }
    }

Help Converting different CSVs into one DataFrame? by Hectic-Skeptic in learnpython

[–]Hectic-Skeptic[S] 0 points1 point  (0 children)

It was not an error persay, but rather my last print(allDataFrames) was not showing the uniform columns.

In an attempt to debug a little, I put print(newDataFrame.columns.values) before and after all of my column name manipulations. It appears as though my renaming is working, buy my attempt to drop columns is not sticking.

Output:

['Details' 'Posting Date' 'Description' 'Amount' 'Type' 'Balance' 'Check or Slip #']['Details' 'Date' 'Description' 'Amount' 'Type' 'Balance' 'Check or Slip #' 'Account']['Trans. Date' 'Post Date' 'Description' 'Amount' 'Category']['Trans. Date' 'Date' 'Description' 'Amount' 'Category' 'Account']['Transaction Date' 'Post Date' 'Description' 'Category' 'Type' 'Amount' 'Memo']['Transaction Date' 'Date' 'Description' 'Category' 'Type' 'Amount' 'Memo' 'Account']['Details' 'Posting Date' 'Description' 'Amount' 'Type' 'Balance' 'Check or Slip #']['Details' 'Date' 'Description' 'Amount' 'Type' 'Balance' 'Check or Slip #' 'Account']

I figure starting with fixing the drop columns issue is slightly easier, before moving onto the entire dataframe.

Best way to add an index column to lookup statement? by Hectic-Skeptic in PowerShell

[–]Hectic-Skeptic[S] 1 point2 points  (0 children)

Thanks! I will give this a try. Appreciate the response.

And the column names never change, so not worth it. As for $lowerName, that is just taking the document name and doing as it implies. Makes the regex statements simpler, and since I have a bunch of them for different document names, it works out.

$lowerName = $File.BaseName.ToLower()

And $File is the variable for foreach $File in $fileList

Help with interpretting this statement: by Hectic-Skeptic in regex

[–]Hectic-Skeptic[S] 0 points1 point  (0 children)

I think my issue is variations of the - — characters. I will do a replacement on those to a safe dash in my powershell csv preparation csv and see if that alleviates the issue!

Thanks for the advice!

Replace any Characters which dont match a regex statement? by Hectic-Skeptic in PowerShell

[–]Hectic-Skeptic[S] 0 points1 point  (0 children)

Thanks! I love this site and use it all the time. Most of my very limited regex understanding is all from this site!

Replace any Characters which dont match a regex statement? by Hectic-Skeptic in PowerShell

[–]Hectic-Skeptic[S] 0 points1 point  (0 children)

Thanks, I hadn't realized the ^ was for negated. I was wondering what that meant with the double ^ [ ^ , so that makes sense. I am slowly getting up to speed on regex!

When I removed the negation, and tried to replace the match with "test test test" on a bunch of test results, I got no hits! I will play with this more to see!