Good day All,
Welcome back and Happy New year to All!!!!!!!!!!!!!!!!!!!
We had requirement to convert FTP logs to a CSV format and to merge then month wise if possible,
Below are the steps i followed.
1. I already had logparser.exe installed on my desktop so incase you dont have just download and install it a very useful log verifying tool.
2. In power shell ISE i changed the path to C:\Program Files (x86)\Log Parser 2.2
$logFilePath="D:\\FTPLogs\"
foreach ($File in (Get-ChildItem $logFilePath))
{
.\logparser.exe -i:W3C -o:csv "SELECT * INTO D:\FTPLogs\$File.csv FROM D:\FTPLogs\$File"
}
3. I converted all the log files to subsequent CSV files..
4. Copied the month wise CSV files and merged then as below
$files = Get-ChildItem D:\FTPLogs\*.csv
Get-Content $files | Set-Content D:\FTPLogs\MergedCsvFile.csv
There may be Powershell guru's who could do it a better way if so please share it to all.. for layman like me managed to get the required result...
Hopefully this helps someone, Until next one you all have good day!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Welcome back and Happy New year to All!!!!!!!!!!!!!!!!!!!
We had requirement to convert FTP logs to a CSV format and to merge then month wise if possible,
Below are the steps i followed.
1. I already had logparser.exe installed on my desktop so incase you dont have just download and install it a very useful log verifying tool.
2. In power shell ISE i changed the path to C:\Program Files (x86)\Log Parser 2.2
$logFilePath="D:\\FTPLogs\"
foreach ($File in (Get-ChildItem $logFilePath))
{
.\logparser.exe -i:W3C -o:csv "SELECT * INTO D:\FTPLogs\$File.csv FROM D:\FTPLogs\$File"
}
3. I converted all the log files to subsequent CSV files..
4. Copied the month wise CSV files and merged then as below
$files = Get-ChildItem D:\FTPLogs\*.csv
Get-Content $files | Set-Content D:\FTPLogs\MergedCsvFile.csv
There may be Powershell guru's who could do it a better way if so please share it to all.. for layman like me managed to get the required result...
Hopefully this helps someone, Until next one you all have good day!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
No comments:
Post a Comment