microsymplex
asked on
Large Data Pool Import & Transpose
Hey all, simple question I'd assume..
I have a notepad file, currently saved as a .log file. I need to import it into Excel. Easy enough, with the import external data feature. My issue arises due to the fact I need to transpose this data, which is easy to do, but I have 255 entries I need transpose. Is there an option / way to specify the transpose when importing the data in excel?
Currently, the data looks like this;
Host Name: No DNS Entry
IP Address: 192.168.1.1
Ping Response: ip dest host unreachable
Ethernet Address:
Network Interface:
Host Type:
Open Ports:
FTP Server:
WINS Name:
Windows Workgroup:
Current User:
WINS Comment:
I need the entire field of 255 IP's transposed across. I can create the horizontal Host Name, IP Address, etc title blocks, but how do I go about transposing the actual data I've gotten off my network scan, without doing it 255 times?
Thanks
I have a notepad file, currently saved as a .log file. I need to import it into Excel. Easy enough, with the import external data feature. My issue arises due to the fact I need to transpose this data, which is easy to do, but I have 255 entries I need transpose. Is there an option / way to specify the transpose when importing the data in excel?
Currently, the data looks like this;
Host Name: No DNS Entry
IP Address: 192.168.1.1
Ping Response: ip dest host unreachable
Ethernet Address:
Network Interface:
Host Type:
Open Ports:
FTP Server:
WINS Name:
Windows Workgroup:
Current User:
WINS Comment:
I need the entire field of 255 IP's transposed across. I can create the horizontal Host Name, IP Address, etc title blocks, but how do I go about transposing the actual data I've gotten off my network scan, without doing it 255 times?
Thanks
ASKER
Attached are my examples. the notepad example is how I get the raw data from my scanning software, netpeek. the green excel cells are how they are getting imported now, the cells in orange are how I want them to be imported, horizontally instead of vertically. Remember I have my entire subnet to do, all 255 addresses, so a simple copy and transpose is not necessarily feasible.
Thanks!
example.txt
example2.xlsx
Thanks!
example.txt
example2.xlsx
Please download the file below, and run the macro GetTheData.
It reads the data from the text file, and writes the results to a new workbook.
It reads the data from the text file, and writes the results to a new workbook.
Sub GetTheData()
Dim fso As Object
Dim ts As Object
Dim ws As Worksheet
Dim FilePath As Variant
Dim UseRow As Long
Dim TheLine As String
Dim Header As String
Dim Item As String
Dim UseCol As Long
FilePath = Application.GetOpenFilename("Text (*.txt), *.txt", , "Select log file", , False)
If FilePath = False Then
MsgBox "No file selected", vbCritical, "Aborting..."
Exit Sub
End If
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(FilePath)
ThisWorkbook.Worksheets(1).Copy
Set ws = ActiveSheet
UseRow = 1
Do Until ts.AtEndOfStream
TheLine = ts.ReadLine
If InStr(1, TheLine, ":") > 0 Then
Header = Split(TheLine, ":")(0)
Item = Trim(Split(TheLine, ":")(1))
If StrComp(Header, "Host Name", vbTextCompare) = 0 Then UseRow = UseRow + 1
UseCol = Application.Match(Header, ws.[1:1], 0)
ws.Cells(UseRow, UseCol) = Item
End If
Loop
ts.Close
Set ts = Nothing
Set fso = Nothing
ws.Columns.AutoFit
MsgBox "Done"
End Sub
Q-25755763.xls
ASKER
Thanks, but when I go to open the text file with all the data (not the example I uploaded) Excel does not list it as an option in the folder where I have it stored.
Change:
FilePath = Application.GetOpenFilenam e("Text (*.txt), *.txt", , "Select log file", , False)
to:
FilePath = Application.GetOpenFilenam e("Log (*.log), *.log", , "Select log file", , False)
FilePath = Application.GetOpenFilenam
to:
FilePath = Application.GetOpenFilenam
ASKER
Disregard the other error, but when I open it, I get a run time error '13': Type Mismatch.
When I run the macro against the sample file you provided, it works perfectly.
Which line did the debugger jump to, and can you post the exact file you tried to run against?
Which line did the debugger jump to, and can you post the exact file you tried to run against?
ASKER
I can't post the exact file, since it has mac addresses, ports, names, ip's, etc. But the format is exactly the same as the example I posted, only it's all 255 IP address, not the 5 or 6 that were included in my example. I apologize for not making that more clear...Yes the macro works with the example, but not the full file I need to run it on in my production environment.
Thanks!
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
will test in the morning, thanks!
ASKER
Ok I'm really sorry but I know nothing except total basics of macros, what do I do with the text you attached?
Hit Alt+F11 to get the VB Editor, and replace the original code I gave you with the updated code in http:#a30146310
ASKER
gotcha.
ASKER
Perfect, exactly what I needed. Thank you for the continued follow up and assistance!
Be sure to first obfuscate any sensitive data in the log :)