
답변1
IMHO 이를 수행하는 가장 쉬운 방법은 Excel의 VBA 매크로입니다.
Sub CleanFiles()
' for each file in a directory
' open it, delete all cell content around the first 20x25 cells, write it back
' 2015-10-15
Dim path As String, aFile As String
Dim arr As Variant
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.EnableEvents = False
path = "D:\TEMP\xls\" ' must have trailing backslash
aFile = Dir(path & "*.xls")
Do While aFile <> ""
Application.StatusBar = aFile
aFile = path & aFile
Workbooks.Open (aFile)
' process file content
arr = ActiveSheet.Range("A1:Y20")
Cells.Clear
ActiveSheet.Range("A1:Y20") = arr
' save and close WB
ActiveWorkbook.Close True, aFile
aFile = Dir
Loop
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.EnableEvents = False
Application.StatusBar = False
End Sub
첫째, 화면 업데이트 및 자동 매크로가 비활성화됩니다. 그런 다음 특정 폴더에서 '*.xls' 파일을 검색하고 각 파일을 엽니다. 보존할 영역의 내용은 내부적으로 저장되었다가 시트 전체가 지워지고 해당 내용이 다시 시트에 기록됩니다. 파일을 닫으면 메시지가 표시되지 않고 저장됩니다.
답변2
Get-Content file.csv | select -First 25 | Export-Csv newfile.csv
처음 20-25개 행을 의미한다면 다음을 수행할 수 있습니다 . a Get-Content -Header @("a","b","c") file.csv | Select a,b,c | Export-Csv newfile.csv
등을 순서대로 수행하여 25번째 열인 y까지 모두 선택할 수 있습니다 . 하지만 더 좋은 방법이 있을 수도 있습니다.