0

I need to add 5 blank space at the beginning into an existing file.

The result now:

1002       9-6-2019 15:44 

This is my code right now:

Import-Csv "C:\Users\.csv" |
    Select-Object "Person ID", "Time" |
    Format-Table -HideTableHeaders -Wrap |
    Out-String -Stream |
    where {$_} |
    foreach { $_.TrimEnd() } |
    foreach { $_ + "`t1`t255`t1`t0" } |
    Out-File C:\Users\.csv

Final output:

BlankspaceX5 1002      9-6-2019 15:44
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Ryna
  • 1
  • 1
  • 5
    Only ever use `Format-*` cmdlets for _display formatting_, never for _programmatic processing_ - see https://stackoverflow.com/a/55174715/45375 Other than that: Please read about [how to ask a good question](http://stackoverflow.com/help/how-to-ask); in particular, explain how your solution attempt relates to the expected outcome. – mklement0 Sep 25 '19 at 01:50
  • 1
    Also, the code you posted does not match your question, as it does not even attempt to prepend spaces to anything. – Ansgar Wiechers Sep 25 '19 at 09:16
  • 1
    As with your [previous question basically about the same thing](https://stackoverflow.com/questions/58072218/how-to-insert-new-data-into-an-existing-file), you need to show an example of the first 3 or 4 lines from the CSV file you are importing. That way, it becomes clear what headers are used and that the file is `TAB` separated or otherwise. What is the purpose of the 5 spaces? (one new empty field or 5?). Also, your code attempts to open and output a csv file without filename... – Theo Sep 25 '19 at 13:09

0 Answers0