Textdatei umformatieren
Hey,
Ich habe folgendes Problem: Ein Programm exportiert bei mir eine Textdatei in dem Format:
erste Zeile mit unnötigem Text
text1,text2,text3,zahl,text4
text1,text2,text3,zahl,text4
text1,text2,text3,zahl,text4
...usw.
Und ich will das am Ende die erste Zeile gelöscht wird, Zeilen mit mehr als 84 Zeichen gelöscht werden und der Inhalt dann so ausschaut:
text2:text3
text2:text3
text2:text3
...usw.
Was für Möglichkeiten gibt es diesen Vorgang zu automatisieren?
Ich habe folgendes Problem: Ein Programm exportiert bei mir eine Textdatei in dem Format:
erste Zeile mit unnötigem Text
text1,text2,text3,zahl,text4
text1,text2,text3,zahl,text4
text1,text2,text3,zahl,text4
...usw.
Und ich will das am Ende die erste Zeile gelöscht wird, Zeilen mit mehr als 84 Zeichen gelöscht werden und der Inhalt dann so ausschaut:
text2:text3
text2:text3
text2:text3
...usw.
Was für Möglichkeiten gibt es diesen Vorgang zu automatisieren?
Please also mark the comments that contributed to the solution of the article
Content-Key: 278921
Url: https://administrator.de/contentid/278921
Printed on: April 23, 2024 at 11:04 o'clock
1 Comment
Hallo bladeyyy,
macht du mit Powershell z.b so:
oder so
Grüße Uwe
macht du mit Powershell z.b so:
$datei = 'C:\temp\data.txt'
(gc $datei) | select -Skip 1 | ?{$_.length -le 84} | %{$parts = $_.split(','); "$($parts[1]):$($parts[2])"} | out-file $datei
$datei = 'C:\temp\data.txt'
((gc $datei) | select -Skip 1 | ?{$_.length -le 84}) -replace '^.*?,(.*?),(.*?),.*','$1:$2' | out-file $datei