I have a file called one_to_many.txt. In the file is the data:
a,aaa
b,bbb
c,ccc
I want to use powershell to create 3 files a.txt, b.txt and c.txt
File a.txt to contain d开发者_如何学运维ata "aaa", b to contain "bbb ...
I'm new to Powershell and can't work out how to do it. Thanks.
One possible solution:
Get-Content one_to_many.txt | Foreach-Object {
  $fileName, $content = $_ -split ','
  $content | Set-Content "$fileName.txt"
}
Get-Content reads the file and returns lines, one by one. Each line is piped to Foreach-Object where it can be accessed as $_. 
You need to split the line by comma, so invoke operator -split which returns in this case array of 2 items. The assignment $filename, $content = .. causes that content of first item in array (from -split) is assigned to $filename and the rest to `$content.
Then simply store that content in the file via Set-Content
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论