Hey everyone. I am a sql programmer who is taking a crash course in Powershell. Brand new to Powershell and also brand new employee at my new job. Been sinking into PowerShell the past couple days. Apologize if this question is very basic and I am very open to feedback on how I can ask this question better.
Here is my scenario: I work for a consulting company that receives client data. So our data source is completely external. We typically work with whatever they send us with no questions asked. The clients typically provide us with a standard set of data that we ask for. In other words, the columns are consistent from customer to customer. Clients typically provide us with csv files filled with data. On occasion, these csv files contain a line above the headers that may contain information. For example, the latest files we received from a client has a row count on line 1. Then on line 2 the headers begin. Is there a way for PowerShell to identify where my headers begin and delete any rows above this. Keep in mind that for some client data we receive, the headers will correctly be on row 1. Each client is different. I am looking for a way to remove any lines above the header. Does (scenario 1) PowerShell have the flexibility to delete when data or rows are above the headers as well as (Scenario 2) know when there is no data above the headers and to do nothing? Hope that makes sense. I do see folks in the forums talking about deleting blank rows or deleting x number of rows. I did not see any discussion that touched on my specific scenario.
What data currently looks like:
|1||Co : ABC||8|
|2||Entity||Entity Name||Year||Employee ID||Employee Name||Payroll Period|
|3||ABC||ABC Company||2019||43445||John Doe||2019|
|4||ABC||ABC Company||2019||23441||Jane Doe||2019|
|5||ABC||ABC Company||2019||46810||Bill Doe||2019|
|6||ABC||ABC Company||2019||99981||Sally Doe||2019|
|7||ABC||ABC Company||2019||52221||Frank Doe||2019|
|8||ABC||ABC Company||2019||99432||Jim Doe||2019|
|9||ABC||ABC Company||2019||12345||Lise Doe||2019|
|10||ABC||ABC Company||2019||98765||Karl Doe||2019|
Below is how I need the file to look:
|1||Entity||Entity Name||Year||Employee ID||Employee Name||Payroll Period|
|2||ABC||ABC Company||2019||43445||John Doe||2019|
|3||ABC||ABC Company||2019||23441||Jane Doe||2019|
|4||ABC||ABC Company||2019||46810||Bill Doe||2019|
|5||ABC||ABC Company||2019||99981||Sally Doe||2019|
|6||ABC||ABC Company||2019||52221||Frank Doe||2019|
|7||ABC||ABC Company||2019||99432||Jim Doe||2019|
|8||ABC||ABC Company||2019||12345||Lise Doe||2019|
|9||ABC||ABC Company||2019||98765||Karl Doe||2019|
Any feedback would be appreciated on whether or not Powershell could accomplish my ask.