Powershell Amateur (AT BEST) needs some help

Welcome Forums General PowerShell Q&A Powershell Amateur (AT BEST) needs some help

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
3 weeks, 2 days ago.

  • Author
    Posts
  • #172333

    Participant
    Topics: 2
    Replies: 1
    Points: 24
    Rank: Member

    Good afternoon all;

    My developer left the company and unfortunately a good chunk of the stuff he was working on has fallen to me.  As such, I have a question which some of you wizards probably know the answer to.

    Situation: I have an undelimited, fixed length file (39 characters wide), approximately 2 million lines provided to us by our illustrious government.  I need to be able to either insert commas at 13 character intervals and once that is done, I need to be able to insert decimal points two characters from the right of column 2 and 3.  I have actually figured out how to do everything else that I need to do but these two items are kicking my posterior (and hurting my pride).

     

    Any help you could offer would be greatly appreciated!

  • #172387

    Participant
    Topics: 1
    Replies: 1528
    Points: 2,581
    Helping Hand
    Rank: Community Hero

    So you are working with strings. You could use the Substring() method to cut a long string into smaller pieces for further use.
    If you'd show your code we might be able to tweak it a little bit for you.

    • #172909

      Participant
      Topics: 2
      Replies: 1
      Points: 24
      Rank: Member

      Thanks Olaf – I ended up figuring this one out doing using substrings as you mentioned.  My script is not elegant but it does work.  🙂

  • #173023

    Participant
    Topics: 0
    Replies: 100
    Points: 363
    Helping Hand
    Rank: Contributor

    Rcoil26,

    Provide us the script to review and see what we can do to make it better? Once the script works the next step is to increase efficiency. I would recommend you to study the Measure-Command commandlet. It's a great command to measure how long a command/ script takes to run.

You must be logged in to reply to this topic.