Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Parsing non deliminated text file

$
0
0

I have a text file that contains information that needs to be imported into SQL table. However, the file isn't delimited in anyway. It contains a header row and the data inline below that. Here is an example:

                           Outstanding      1-15 Days    16-30 Days      31-45 Days     46-65 Days
Student Name      Amount            Past Due      Past Due           Past Due          Past Due       
------------------     ---------------  ------------    ------------       ------------     ------------
DEYOU, KATINA P                 -5.00            0.00              0.00                 0.00               0.00

The only regualarity to the data is that the column length is denotes by the length of the hyphens and these can vary depending on the longest student name in the column. I what I need is a PowerShell script that will evaluate the length of each column by counting the number of hyphens (characters) for each column and save that information to variables. I then would need to read each line in the file and insert a comma at the end of each data element of in the columns. Like this:

                           Outstanding      1-15 Days    16-30 Days      31-45 Days     46-65 Days
Student Name      Amount            Past Due      Past Due           Past Due          Past Due       
-------------------     ---------------  ------------    ------------       ------------     -------------
DEYOU, KATINA P,                 -5.00,          0.00,             0.00,                0.00,               0.00,

Can anyone help me to solve this problem?

Thanks


Support Analyst / Support Engineer


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>