Find strings from one text file in another - parsing
Trying to loop through my error.log file and match strings in another Map.log (text) file. I think I'm looping incorrectly as the script ends after it has matched the first line in the error.log file against each line in the other Map.log file. After doing that, it should be moving to the next line in the error.log and comparing against all in Map.log, etc.
The reason I need to do this is the error.log file doesn't contain enough info to pinpoint the source of the problem, but it does contain the date and times. I've been manually matching those up with the info in the Map.log file to see the specific cause, but there can be thousands of lines in the Map.log file. This would remedy that. Basically, I want to match the date/time from error.log in map.log and pull out the corresponding "FcId: #". An ideal result would be:
3/14/2016 1:20:35 PM: FcId: 98766
3/14/2016 1:20:39 PM: FcId: 46253
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set ERROR_logfilename = fso.OpenTextFile(fso.GetParentFolderName(WScript.ScriptFullName) & "\Error.log")
Set MAP_logfilename = fso.OpenTextFile(fso.GetParentFolderName(WScript.ScriptFullName) & "\Map.log")
'==============================
'This section pulls all of the date and time strings in the error.log file
'for matching in the maps.log file (everything before the first comma).
Do While Not ERROR_logfilename.AtEndOfStream
arrStr = Split(ERROR_logfilename.ReadLine, ",")
strError = arrStr(0)
'==============================
Do While Not MAP_logfilename.AtEndOfStream
strLogItem = MAP_logfilename.ReadLine
If InStr(strLogItem, strError) Then
WScript.Echo strLogItem
End If
Loop
Loop
ERROR_logfilename.Close
MAP_logfilename.Close
The error.log file contains lines like:
3/14/2016 1:20:35 PM,Warning in List.
3/14/2016 1:20:39 PM,Warning in List.
The map.log file contains lines like this:
3/14/2016 1:20:34 PM,key_id: 1 FcId: 987766 ac_id: 987763 prim_1_eftv_dttm: 8/11/2014 prim_2_eftv_dttm: 8/11/2014
3/14/2016 1:20:34 PM,key_id: 1 FcId: 987766 svr_id: 2872158 br_FcId: 987764 eftv_dttm: 8/11/2014 term_dttm: 3/14/2016 top_md_qty: 1470 btm_md_qty: 1551
3/14/2016 1:20:34 PM,Record count: 2
3/14/2016 1:20:34 PM,List.calcLength() Calculated : FcId: 987766 currentDate: 8/11/2014 Length: 81 with 1 webo(s).
3/14/2016 1:20:35 PM,RESULT for FcId: 987766 GnId: 2585 lbrFcId:: 987764 SeqId: 1 Length: 81 Top: 1470 Btm: 1551 on Date: 8/11/2014
3/14/2016 1:20:35 PM,Date Range for completion: 987766 : 8/11/2014 12:00:00 AM - 3/14/2016 12:00:00 AM
3/14/2016 1:20:35 PM,Processed record: 11 Id: 987766
3/14/2016 1:20:35 PM,End:
3/14/2016 1:20:35 PM,Begin:
3/14/2016 1:20:36 PM,key_id: 1 FcId: 29910 ac_id: 29908 prim_1_eftv_dttm: 12/1/1998 prim_2_eftv_dttm: 12/1/1998
3/14/2016 1:20:36 PM,key_id: 2 FcId: 29910 ac_id: 29908 prim_1_eftv_dttm: 10/1/2000 prim_2_eftv_dttm: 10/1/2000
3/14/2016 1:20:36 PM,key_id: 1 FcId: 29910 svr_id: 350499 br_FcId: 29909 eftv_dttm: 12/1/1998 term_dttm: 10/1/2000 top_md_qty: 1270 btm_md_qty: 1350
3/14/2016 1:20:36 PM,key_id: 2 FcId: 29910 svr_id: 350500 br_FcId: 29909 eftv_dttm: 12/1/1998 term_dttm: 10/1/2000 top_md_qty: 1390 btm_md_qty: 1560
3/14/2016 1:20:36 PM,key_id: 3 FcId: 29910 svr_id: 350501 br_FcId: 29909 eftv_dttm: 12/1/1998 term_dttm: 3/14/2016 top_md_qty: 1620 btm_md_qty: 1800
3/14/2016 1:20:36 PM,key_id: 4 FcId: 29910 svr_id: 350502 br_FcId: 29909 eftv_dttm: 12/1/1998 term_dttm: 3/14/2016 top_md_qty: 1840 btm_md_qty: 2020
3/14/2016 1:20:36 PM,Record count: 2
3/14/2016 1:20:36 PM,List.calcLength() Calculated : FcId: 29910 currentDate: 12/1/1998 Length: 750 with 1 webo(s).
3/14/2016 1:20:36 PM,RESULT for FcId: 29910 GnId: 3997 lbrFcId:: 29909 SeqId: 1 Length: 82.51 Top: 1270 Btm: 1352.51 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2584 lbrFcId:: 29909 SeqId: 2 Length: 106.27 Top: 1352.51 Btm: 1458.78 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 3998 lbrFcId:: 29909 SeqId: 3 Length: 122.22 Top: 1458.78 Btm: 1581 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 3999 lbrFcId:: 29909 SeqId: 4 Length: 48.43 Top: 1581 Btm: 1629.43 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2588 lbrFcId:: 29909 SeqId: 5 Length: 76.06 Top: 1629.43 Btm: 1705.49 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2592 lbrFcId:: 29909 SeqId: 6 Length: 34.81 Top: 1705.49 Btm: 1740.3 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2594 lbrFcId:: 29909 SeqId: 7 Length: 16.43 Top: 1740.3 Btm: 1756.73 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2595 lbrFcId:: 29909 SeqId: 8 Length: 25.27 Top: 1756.73 Btm: 1782 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2597 lbrFcId:: 29909 SeqId: 9 Length: 43.5 Top: 1782 Btm: 1825.5 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2598 lbrFcId:: 29909 SeqId: 10 Length: 19.97 Top: 1825.5 Btm: 1845.47 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2599 lbrFcId:: 29909 SeqId: 11 Length: 19.53 Top: 1845.47 Btm: 1865 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2600 lbrFcId:: 29909 SeqId: 12 Length: 8.67 Top: 1865 Btm: 1873.67 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 4007 lbrFcId:: 29909 SeqId: 13 Length: 43.33 Top: 1873.67 Btm: 1917 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2603 lbrFcId:: 29909 SeqId: 14 Length: 45.24 Top: 1917 Btm: 1962.24 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2605 lbrFcId:: 29909 SeqId: 15 Length: 19.76 Top: 1962.24 Btm: 1982 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 3989 lbrFcId:: 29909 SeqId: 16 Length: 14.98 Top: 1982 Btm: 1996.98 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2607 lbrFcId:: 29909 SeqId: 17 Length: 15.82 Top: 1996.98 Btm: 2012.8 on Date: 12/1/1998
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 3990 lbrFcId:: 29909 SeqId: 18 Length: 7.2 Top: 2012.8 Btm: 2020 on Date: 12/1/1998
3/14/2016 1:20:37 PM,Date Range for completion: 29910 : 12/1/1998 12:00:00 AM - 10/1/2000 12:00:00 AM
3/14/2016 1:20:37 PM,Record count: 2
3/14/2016 1:20:37 PM,List.calcLength() Calculated : FcId: 29910 currentDate: 10/1/2000 Length: 400 with 1 webo(s).
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 3999 lbrFcId:: 29909 SeqId: 1 Length: 9.43 Top: 1620 Btm: 1629.43 on Date: 10/1/2000
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2588 lbrFcId:: 29909 SeqId: 2 Length: 76.06 Top: 1629.43 Btm: 1705.49 on Date: 10/1/2000
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2592 lbrFcId:: 29909 SeqId: 3 Length: 34.81 Top: 1705.49 Btm: 1740.3 on Date: 10/1/2000
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2594 lbrFcId:: 29909 SeqId: 4 Length: 16.43 Top: 1740.3 Btm: 1756.73 on Date: 10/1/2000
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2595 lbrFcId:: 29909 SeqId: 5 Length: 25.27 Top: 1756.73 Btm: 1782 on Date: 10/1/2000
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2597 lbrFcId:: 29909 SeqId: 6 Length: 43.5 Top: 1782 Btm: 1825.5 on Date: 10/1/2000
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2598 lbrFcId:: 29909 SeqId: 7 Length: 19.97 Top: 1825.5 Btm: 1845.47 on Date: 10/1/2000
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2599 lbrFcId:: 29909 SeqId: 8 Length: 19.53 Top: 1845.47 Btm: 1865 on Date: 10/1/2000
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 2600 lbrFcId:: 29909 SeqId: 9 Length: 8.67 Top: 1865 Btm: 1873.67 on Date: 10/1/2000
3/14/2016 1:20:37 PM,RESULT for FcId: 29910 GnId: 4007 lbrFcId:: 29909 SeqId: 10 Length: 43.33 Top: 1873.67 Btm: 1917 on Date: 10/1/2000
3/14/2016 1:20:38 PM,RESULT for FcId: 29910 GnId: 2603 lbrFcId:: 29909 SeqId: 11 Length: 45.24 Top: 1917 Btm: 1962.24 on Date: 10/1/2000
3/14/2016 1:20:38 PM,RESULT for FcId: 29910 GnId: 2605 lbrFcId:: 29909 SeqId: 12 Length: 19.76 Top: 1962.24 Btm: 1982 on Date: 10/1/2000
3/14/2016 1:20:38 PM,RESULT for FcId: 29910 GnId: 3989 lbrFcId:: 29909 SeqId: 13 Length: 14.98 Top: 1982 Btm: 1996.98 on Date: 10/1/2000
3/14/2016 1:20:38 PM,RESULT for FcId: 29910 GnId: 2607 lbrFcId:: 29909 SeqId: 14 Length: 15.82 Top: 1996.98 Btm: 2012.8 on Date: 10/1/2000
3/14/2016 1:20:38 PM,RESULT for FcId: 29910 GnId: 3990 lbrFcId:: 29909 SeqId: 15 Length: 7.2 Top: 2012.8 Btm: 2020 on Date: 10/1/2000
3/14/2016 1:20:38 PM,Date Range for completion: 29910 : 10/1/2000 12:00:00 AM - 3/14/2016 12:00:00 AM
3/14/2016 1:20:38 PM,Processed record: 12 Id: 29910
3/14/2016 1:20:38 PM,End:
3/14/2016 1:20:38 PM,Begin:
3/14/2016 1:20:38 PM,key_id: 1 FcId: 987765 ac_id: 987763 prim_1_eftv_dttm: 8/11/2014 prim_2_eftv_dttm: 8/11/2014
3/14/2016 1:20:38 PM,key_id: 1 FcId: 987765 svr_id: 2872159 br_FcId: 987764 eftv_dttm: 8/11/2014 term_dttm: 3/14/2016 top_md_qty: 1750 btm_md_qty: 1791
3/14/2016 1:20:38 PM,Record count: 2
3/14/2016 1:20:38 PM,List.calcLength() Calculated : FcId: 987765 currentDate: 8/11/2014 Length: 41 with 1 webo(s).
3/14/2016 1:20:39 PM,RESULT for FcId: 987765 GnId: 2585 lbrFcId:: 987764 SeqId: 1 Length: 41 Top: 1750 Btm: 1791 on Date: 8/11/2014
3/14/2016 1:20:39 PM,Date Range for completion: 987765 : 8/11/2014 12:00:00 AM - 3/14/2016 12:00:00 AM
3/14/2016 1:20:39 PM,Processed record: 13 Id: 987765
3/14/2016 1:20:39 PM,End:
3/14/2016 1:20:39 PM,Begin:
3/14/2016 1:20:39 PM,key_id: 1 FcId: 46253 ac_id: 46251 prim_1_eftv_dttm: 12/1/1991 prim_2_eftv_dttm: 12/1/1991
3/14/2016 1:20:39 PM,key_id: 2 FcId: 46253 ac_id: 46251 prim_1_eftv_dttm: 6/1/1998 prim_2_eftv_dttm: 6/1/1998
3/14/2016 1:20:39 PM,key_id: 1 FcId: 46253 svr_id: 133009 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 890 btm_md_qty: 911
3/14/2016 1:20:39 PM,key_id: 2 FcId: 46253 svr_id: 133010 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 911 btm_md_qty: 968
3/14/2016 1:20:39 PM,key_id: 3 FcId: 46253 svr_id: 133011 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 968 btm_md_qty: 1036
3/14/2016 1:20:39 PM,key_id: 4 FcId: 46253 svr_id: 133013 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1036 btm_md_qty: 1070
3/14/2016 1:20:39 PM,key_id: 5 FcId: 46253 svr_id: 133015 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1090 btm_md_qty: 1120
3/14/2016 1:20:39 PM,key_id: 6 FcId: 46253 svr_id: 133017 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1120 btm_md_qty: 1172
3/14/2016 1:20:39 PM,key_id: 7 FcId: 46253 svr_id: 133018 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1172 btm_md_qty: 1220
3/14/2016 1:20:39 PM,key_id: 8 FcId: 46253 svr_id: 133021 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1240 btm_md_qty: 1320
3/14/2016 1:20:39 PM,key_id: 9 FcId: 46253 svr_id: 133024 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1320 btm_md_qty: 1380
3/14/2016 1:20:39 PM,key_id: 10 FcId: 46253 svr_id: 133026 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1400 btm_md_qty: 1430
3/14/2016 1:20:39 PM,key_id: 11 FcId: 46253 svr_id: 133027 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1430 btm_md_qty: 1450
3/14/2016 1:20:39 PM,key_id: 12 FcId: 46253 svr_id: 133030 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1450 btm_md_qty: 1510
3/14/2016 1:20:39 PM,key_id: 13 FcId: 46253 svr_id: 133031 br_FcId: 46252 eftv_dttm: 10/16/1991 term_dttm: 3/14/2016 top_md_qty: 1510 btm_md_qty: 1540
3/14/2016 1:20:39 PM,Record count: 2
3/14/2016 1:20:39 PM,List.calcLength() Calculated : FcId: 46253 currentDate: 12/1/1991 Length: 650 with 1 webo(s).
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 2584 lbrFcId:: 46252 SeqId: 1 Length: 40.86 Top: 890 Btm: 930.86 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 3998 lbrFcId:: 46252 SeqId: 2 Length: 99.04 Top: 930.86 Btm: 1029.9 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 3999 lbrFcId:: 46252 SeqId: 3 Length: 55.1 Top: 1029.9 Btm: 1085 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 2588 lbrFcId:: 46252 SeqId: 4 Length: 81.13 Top: 1085 Btm: 1166.13 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 2592 lbrFcId:: 46252 SeqId: 5 Length: 59.17 Top: 1166.13 Btm: 1225.3 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 2594 lbrFcId:: 46252 SeqId: 6 Length: 62.35 Top: 1225.3 Btm: 1287.65 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 2597 lbrFcId:: 46252 SeqId: 7 Length: 141.25 Top: 1287.65 Btm: 1428.9 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 4007 lbrFcId:: 46252 SeqId: 8 Length: 15.7 Top: 1428.9 Btm: 1444.6 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 2603 lbrFcId:: 46252 SeqId: 9 Length: 54.36 Top: 1444.6 Btm: 1498.96 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 2605 lbrFcId:: 46252 SeqId: 10 Length: 29.7 Top: 1498.96 Btm: 1528.66 on Date: 12/1/1991
3/14/2016 1:20:40 PM,RESULT for FcId: 46253 GnId: 3989 lbrFcId:: 46252 SeqId: 11 Length: 11.34 Top: 1528.66 Btm: 1540 on Date: 12/1/1991
You may need to adjust it so that it picks up the right line feed.
'===================================
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set ERROR_logfilename = fso.OpenTextFile(fso.GetParentFolderName(wscript.ScriptFullName) & "\Error.log")
Set MAP_logfilename = fso.OpenTextFile(fso.GetParentFolderName(wscript.ScriptFullName) & "\Map.log")
errorContents = Split(ERROR_logfilename.ReadAll, vbCrLf) 'get the contents and split on the line feed
mapContents = Split(MAP_logfilename.ReadAll, vbCrLf)
ERROR_logfilename.Close 'close the file
MAP_logfilename.Close
For i = 0 To UBound(errorContents) - 1 'loop through error log contents
arrStr = Split(errorContents(i), ",")
strError = arrStr(0)
For j = 0 To UBound(mapContents) - 1 'loop through map log contents
If InStr(mapContents(j), strError) Then
wscript.echo strError & " " & strMap
End If
Next j
Next i
This is the final script I ended up with thanks to Sorceri's help.
'===================================
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set ERROR_logfilename = fso.OpenTextFile(fso.GetParentFolderName(wscript.ScriptFullName) & "\Error.log")
Set MAP_logfilename = fso.OpenTextFile(fso.GetParentFolderName(wscript.ScriptFullName) & "\Map.log")
strOutputFileName = fso.GetParentFolderName(WScript.ScriptFullName) & "\Error_Clean.log"
Set objFile = fso.OpenTextFile(strOutputFileName, 2 , true) 'Clear old errors
objFile.Write ""
objFile.Close
errorContents = Split(ERROR_logfilename.ReadAll, vbCrLf) 'get the contents and split on the line feed
mapContents = Split(MAP_logfilename.ReadAll, vbCrLf)
ERROR_logfilename.Close 'close the file
MAP_logfilename.Close
For i = 0 To UBound(errorContents) - 1 'loop through error log contents
arrStr = Split(errorContents(i), ",")
strError = arrStr(0)
For j = 0 To UBound(mapContents) - 1 'loop through map log contents
If InStr(mapContents(j), strError) and InStr(mapContents(j), "PM,Processed record: ") Then
arrStr1 = Split(mapContents(j),"CmplId: ")
strMapContents = arrStr1(1)
'wscript.echo strError & vbCrlF & "Cmpl_Fac_ID: " & strMapContents
CleanErrors = strError & vbCrlF & "Cmpl_Fac_ID: " & strMapContents & vbCrlF
Set objFile = fso.OpenTextFile(strOutputFileName, 8 , true) 'Write new errors
objFile.WriteLine CleanErrors
objFile.Close
End If
Next
Next
'==================================
Related
How to Convert String into bytearray(EUC-KR)?
Hello There i am using swift 5.0 and developing BLE App. As we have android app there are using default function as below byte nByte[] = Name.getBytes( charsetName: "EUC-KR") Output of android Value[0] = 32 Value[1] = 30 Value[2] = 32 Value[3] = 32 Value[4] = 31 Value[5] = 31 Value[6] = 32 Value[7] = 37 Value[8] = 2d Value[9] = c3 Value[10] = e6 Value[11] = ba Value[12] = cf Value[13] = 38 Value[14] = 30 Value[15] = c0 Value[16] = da Value[17] = 39 Value[18] = 30 Value[19] = 31 Value[20] = 35 Value[21] = 2d Value[22] = 58 Value[23] = 2d Value[24] = 30 Value[25] = 32 Value[26] = 2d Value[27] = 31 Value[28] = 32 Value[29] = 31 Value[30] = 32 Value[31] = 31 Value[32] = 32 Value[33] = 31 Value[34] = 2e Value[35] = 54 Value[36] = 58 Value[37] = 54 We used in iOS different type of string convert as below Code 1 let rawEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(CFStringEncodings.EUC_KR.rawValue)) let encoding = String.Encoding(rawValue: rawEncoding) let strEUCData = "20221127-충북80자9015-X-02-1212121.TXT".data(using: encoding) ?? Data() Output of iOS bytes : 38 elements 0 : 50 1 : 48 2 : 50 3 : 50 4 : 49 5 : 49 6 : 50 8 : 45 9 : 195 10 : 230 11 : 186 12 : 207 13 : 56 14 : 48 15 : 192 16 : 218 17 : 57 18 : 48 19 : 49 20 : 53 21 : 45 22 : 88 23 : 45 24 : 48 25 : 50 26 : 45 27 : 49 28 : 50 29 : 49 30 : 50 31 : 49 32 : 50 33 : 49 34 : 46 35 : 84 36 : 88 37 : 84 Code 2 let strEUCData1 = "20221127-충북80자9015-X-02-1212121.TXT".data(using: String.Encoding(rawValue: 0x80000940)) ?? Data() All above functions given wrong byte array. Any help will be appreciated. Thank you.
They are the same data. The Android output is in Hex (base 16) number and the iOS output is in decimal (base 10) number: Android (Hex) iOS (Decimal) 32 50 30 48 32 50 32 50 31 49 31 49 32 50 37 55 2d 45 c3 195 e6 230 ba 186 cf 207 38 56 30 48 c0 192 da 218 39 57 30 48 31 49 35 53 2d 45 58 88 2d 45 30 48 32 50 2d 45 31 49 32 50 31 49 32 50 31 49 32 50 31 49 2e 46 54 84 58 88 54 84
Generated DXF file opens in AutoCAD but crashes BricsCAD
I am working on a DXF (AC1021 version) exporter in Delphi and I ran into some problems. I was looking closely at ezdxf for minimum file structure and I was able to successfully generate it in delphi. Now the problem I have is that the generated file works OK in AutoCAD but chrashes BricsCAD as soon as I try to click on entity from block. Below I am sending you my generated file. Maybe somebody knows an analyzing tool are maybe has an idea what is wrong with my dxf exporter.Thanks for all the hints! 999 TFPDxfWriteBridge by wingdesigner 0 SECTION 2 HEADER 9 $ACADVER 1 AC1021 9 $HANDSEED 5 20000 0 ENDSEC 0 SECTION 2 CLASSES 0 ENDSEC 0 SECTION 2 TABLES 0 TABLE 2 VPORT 5 A 330 0 100 AcDbSymbolTable 70 1 0 VPORT 5 B 330 A 100 AcDbSymbolTableRecord 100 AcDbViewportTableRecord 2 *ACTIVE 70 0 10 0 20 0 11 1 21 1 12 209 22 86 13 0 23 0 14 10 24 10 15 1 25 1 16 0 26 0 36 1 17 0 27 0 37 0 40 319 41 2 42 50 43 0 44 0 50 0 51 0 71 0 72 100 73 1 74 3 75 0 76 0 77 0 78 0 281 0 65 1 110 0 120 0 130 0 111 1 121 0 131 0 112 0 122 1 132 0 79 0 146 0 348 10020 60 7 61 5 292 1 282 1 141 0 142 0 63 250 421 3358443 0 ENDTAB 0 TABLE 2 LTYPE 5 C 330 0 100 AcDbSymbolTable 70 4 0 LTYPE 5 D 330 C 100 AcDbSymbolTableRecord 100 AcDbLinetypeTableRecord 2 ByBlock 70 0 3 72 65 73 0 40 0.000 0 LTYPE 5 E 330 C 100 AcDbSymbolTableRecord 100 AcDbLinetypeTableRecord 2 ByLayer 70 0 3 72 65 73 0 40 0.000 0 LTYPE 5 F 330 C 100 AcDbSymbolTableRecord 100 AcDbLinetypeTableRecord 2 CONTINUOUS 70 0 3 Solid line 72 65 73 0 40 0.000 0 ENDTAB 0 TABLE 2 LAYER 5 10 330 0 100 AcDbSymbolTable 70 1 0 LAYER 5 11 330 10 100 AcDbSymbolTableRecord 100 AcDbLayerTableRecord 2 0 70 0 62 7 6 CONTINUOUS 370 -3 390 F 0 ENDTAB 0 TABLE 2 STYLE 5 12 330 0 100 AcDbSymbolTable 70 3 0 STYLE 5 13 330 12 100 AcDbSymbolTableRecord 100 AcDbTextStyleTableRecord 2 Standard 70 0 40 0.00 41 1.00 50 0.00 71 0 42 1.00 3 txt 4 0 ENDTAB 0 TABLE 2 VIEW 5 15 330 0 100 AcDbSymbolTable 70 0 0 ENDTAB 0 TABLE 2 UCS 5 17 330 0 100 AcDbSymbolTable 70 0 0 ENDTAB 0 TABLE 2 APPID 5 18 330 0 100 AcDbSymbolTable 70 1 0 APPID 5 19 330 18 100 AcDbSymbolTableRecord 100 AcDbRegAppTableRecord 2 ACAD 70 0 0 ENDTAB 0 TABLE 2 DIMSTYLE 5 1A 330 0 100 AcDbSymbolTable 70 1 100 AcDbDimStyleTable 71 1 0 DIMSTYLE 105 1B 330 1A 100 AcDbSymbolTableRecord 100 AcDbDimStyleTableRecord 2 Standard 70 0 40 1 41 0.18 42 0.0625 43 0.38 44 0.18 45 0 46 0.00 47 0.0 48 0.0 140 0.18 141 0.09 142 0.0 143 25.39999 144 1.0 145 0.0 146 1.0 147 0.09 148 0 71 0 72 0 73 0 74 1 75 0 76 0 77 0 78 0 79 0 170 0 171 2 172 0 173 0 174 0 175 0 176 0 177 0 178 0 179 0 271 4 272 4 273 2 274 2 275 0 276 0 277 2 278 46 279 0 280 0 281 0 282 0 283 1 284 0 285 0 286 0 288 0 289 3 340 Standard 341 371 -2 372 -2 0 ENDTAB 0 TABLE 2 BLOCK_RECORD 5 1C 330 0 100 AcDbSymbolTable 70 2 0 BLOCK_RECORD 5 1D 330 1C 100 AcDbSymbolTableRecord 100 AcDbBlockTableRecord 2 *Model_Space 70 0 280 1 281 0 0 BLOCK_RECORD 5 21 330 1C 100 AcDbSymbolTableRecord 100 AcDbBlockTableRecord 2 *Paper_Space 70 0 280 1 281 0 0 BLOCK_RECORD 5 25 330 1C 100 AcDbSymbolTableRecord 100 AcDbBlockTableRecord 2 TEST_BLOCK 70 0 280 1 281 0 0 ENDTAB 0 ENDSEC 0 SECTION 2 BLOCKS 0 BLOCK 5 1E 330 1D 100 AcDbEntity 8 0 100 AcDbBlockBegin 2 *Model_Space 70 0 10 0.00 20 0.00 30 0.0 3 *Model_Space 1 0 ENDBLK 5 20 330 1D 100 AcDbEntity 8 0 100 AcDbBlockEnd 0 BLOCK 5 22 330 21 100 AcDbEntity 8 0 100 AcDbBlockBegin 2 *Paper_Space 70 0 10 0.00 20 0.00 30 0.0 3 *Paper_Space 1 0 ENDBLK 5 24 330 21 100 AcDbEntity 8 0 100 AcDbBlockEnd 0 BLOCK 5 26 330 25 100 AcDbEntity 8 0 100 AcDbBlockBegin 2 TEST_BLOCK 70 0 10 0.00 20 0.00 30 0.0 3 TEST_BLOCK 1 0 LINE 5 27 330 25 100 AcDbEntity 8 0 100 AcDbLine 10 1688.00 20 1430.00 30 0.00 11 1185.00 21 1097.00 31 0.00 0 POINT 5 28 330 25 100 AcDbEntity 8 0 100 AcDbPoint 10 1715.00 20 1205.00 30 0.00 0 CIRCLE 5 29 330 25 100 AcDbEntity 8 0 100 AcDbCircle 10 847.31 20 1694.50 30 0.00 40 272.44 0 ARC 5 2A 330 25 100 AcDbEntity 8 0 100 AcDbCircle 10 595.07 20 875.17 30 0.00 40 384.38 100 AcDbArc 50 232.00 51 224.00 0 LWPOLYLINE 5 2B 330 25 100 AcDbEntity 8 0 100 AcDbPolyline 90 10 70 0 10 1783.00 20 113.00 10 1927.00 20 545.00 10 766.00 20 955.00 10 1583.00 20 1624.00 10 1057.00 20 959.00 10 1136.00 20 785.00 10 1851.00 20 1672.00 10 142.00 20 674.00 10 174.00 20 1296.00 10 40.00 20 736.00 0 SPLINE 5 2C 330 25 100 AcDbEntity 8 0 100 AcDbSpline 210 0.0 220 0.0 230 1.0 70 8 71 3 72 14 73 10 74 0 42 0.0000000001 43 0.0000000001 40 0.00000 40 0.00000 40 0.00000 40 0.00000 40 1.00000 40 2.00000 40 3.00000 40 4.00000 40 5.00000 40 5.00000 40 5.00000 40 5.00000 40 5.00000 40 5.00000 10 1783.00 20 113.00 30 0.0 10 1927.00 20 545.00 30 0.0 10 766.00 20 955.00 30 0.0 10 1583.00 20 1624.00 30 0.0 10 1057.00 20 959.00 30 0.0 10 1136.00 20 785.00 30 0.0 10 1851.00 20 1672.00 30 0.0 10 142.00 20 674.00 30 0.0 10 174.00 20 1296.00 30 0.0 10 40.00 20 736.00 30 0.0 0 ENDBLK 5 2D 330 25 100 AcDbEntity 8 0 100 AcDbBlockEnd 0 ENDSEC 0 SECTION 2 ENTITIES 0 INSERT 5 2E 330 25 100 AcDbEntity 8 0 100 AcDbBlockReference 2 TEST_BLOCK 10 0.00 20 0.00 30 0.0 0 ENDSEC 0 SECTION 2 OBJECTS 0 DICTIONARY 5 2F 330 0 100 AcDbDictionary 281 1 3 ACAD_GROUP 350 D 0 DICTIONARY 5 30 330 2F 100 AcDbDictionary 281 1 0 ENDSEC 0 EOF EDIT As it turnes out, BricsCAD has a nice recover tool. Acoording to that tool Hard POinter/ID Handle of PlotStyleName Object (390) is wrong. Name: AcDbLayerTableRecord(17); Value: PlotStyleName Id (F); Validation: Invalid; Replaced by: Set to Null. This narrows the possibilites a lot, but doesn't quite solve the problem, as I am not really sure what PlotStyleName object is in my case.
I found out that BricsCAD can use internal _RECOVER function to analyze the input file and warn the user of possible errors. As it turns out, self pointers of layers (390) were not correctly defined. Setting 390 to 0 instead of F, is not the cleanest and the most correct way to solve the problem but it does the job.
I don't know about BricsCAD but It could be some of the AutoCAD-friendly dxf codes that are not supported by BricsCAD. Try this dxf file to see if it generates the same error in BricsCAD It contains one block only (Zoom-Extends to find it). If it works we can figure-out what made your file crash. 0 SECTION 2 HEADER 9 $ACADVER 1 AC1009 9 $INSBASE 10 0.0 20 0.0 30 0.0 9 $REGENMODE 70 1 9 $FILLMODE 70 1 9 $QTEXTMODE 70 0 9 $MIRRTEXT 70 0 9 $DRAGMODE 70 2 9 $LTSCALE 40 1.0 9 $OSMODE 70 2215 9 $ATTMODE 70 1 9 $TEXTSIZE 40 0.15 9 $TRACEWID 40 1.0 9 $TEXTSTYLE 7 STANDARD 9 $CLAYER 8 DEFPOINTS 9 $CELTYPE 6 BYLAYER 9 $CECOLOR 62 256 9 $DIMSCALE 40 1.0 9 $DIMASZ 40 0.1 9 $DIMEXO 40 0.25 9 $DIMDLI 40 0.25 9 $DIMRND 40 0.0 9 $DIMDLE 40 0.0 9 $DIMEXE 40 0.1 9 $DIMTP 40 0.0 9 $DIMTM 40 0.0 9 $DIMTXT 40 0.15 9 $DIMCEN 40 0.1 9 $DIMTSZ 40 0.0 9 $DIMTOL 70 0 9 $DIMLIM 70 0 9 $DIMTIH 70 0 9 $DIMTOH 70 1 9 $DIMSE1 70 0 9 $DIMSE2 70 0 9 $DIMTAD 70 1 9 $DIMZIN 70 8 9 $DIMBLK 1 9 $DIMASO 70 1 9 $DIMSHO 70 1 9 $DIMPOST 1 9 $DIMAPOST 1 9 $DIMALT 70 0 9 $DIMALTD 70 3 9 $DIMALTF 40 0.03937007874016 9 $DIMLFAC 40 1.0 9 $DIMTOFL 70 1 9 $DIMTVP 40 0.0 9 $DIMTIX 70 0 9 $DIMSOXD 70 0 9 $DIMSAH 70 0 9 $DIMBLK1 1 9 $DIMBLK2 1 9 $DIMSTYLE 2 ISO-25 9 $DIMCLRD 70 2 9 $DIMCLRE 70 0 9 $DIMCLRT 70 7 9 $DIMTFAC 40 1.0 9 $DIMGAP 40 0.15 9 $LUNITS 70 2 9 $LUPREC 70 3 9 $SKETCHINC 40 1.0 9 $FILLETRAD 40 0.0 9 $AUNITS 70 1 9 $AUPREC 70 3 9 $MENU 1 . 9 $ELEVATION 40 0.0 9 $PELEVATION 40 0.0 9 $THICKNESS 40 0.0 9 $LIMCHECK 70 0 9 $BLIPMODE 70 0 9 $CHAMFERA 40 0.0 9 $CHAMFERB 40 0.0 9 $SKPOLY 70 0 9 $TDCREATE 40 2455559.7215111339 9 $TDUPDATE 40 2455601.6499361689 9 $TDINDWG 40 0.0182150694 9 $TDUSRTIMER 40 0.0182009375 9 $USRTIMER 70 1 9 $ANGBASE 50 0.0 9 $ANGDIR 70 0 9 $PDMODE 70 0 9 $PDSIZE 40 0.0 9 $PLINEWID 40 0.0 9 $COORDS 70 1 9 $SPLFRAME 70 0 9 $SPLINETYPE 70 6 9 $SPLINESEGS 70 8 9 $ATTDIA 70 0 9 $ATTREQ 70 1 9 $HANDLING 70 1 9 $HANDSEED 5 100006 9 $SURFTAB1 70 6 9 $SURFTAB2 70 6 9 $SURFTYPE 70 6 9 $SURFU 70 6 9 $SURFV 70 6 9 $UCSNAME 2 9 $UCSORG 10 0.0 20 0.0 30 0.0 9 $UCSXDIR 10 1.0 20 0.0 30 0.0 9 $UCSYDIR 10 0.0 20 1.0 30 0.0 9 $PUCSNAME 2 9 $PUCSORG 10 0.0 20 0.0 30 0.0 9 $PUCSXDIR 10 1.0 20 0.0 30 0.0 9 $PUCSYDIR 10 0.0 20 1.0 30 0.0 9 $USERI1 70 0 9 $USERI2 70 0 9 $USERI3 70 0 9 $USERI4 70 0 9 $USERI5 70 0 9 $USERR1 40 0.0 9 $USERR2 40 0.0 9 $USERR3 40 0.0 9 $USERR4 40 0.0 9 $USERR5 40 0.0 9 $WORLDVIEW 70 1 9 $SHADEDGE 70 3 9 $SHADEDIF 70 70 9 $TILEMODE 70 1 9 $MAXACTVP 70 64 9 $PLIMCHECK 70 0 9 $PEXTMIN 10 1.0000000000000000E+020 20 1.0000000000000000E+020 30 1.0000000000000000E+020 9 $PEXTMAX 10 -1.0000000000000000E+020 20 -1.0000000000000000E+020 30 -1.0000000000000000E+020 9 $PLIMMIN 10 0.0 20 0.0 9 $PLIMMAX 10 420.0 20 297.0 9 $UNITMODE 70 0 9 $VISRETAIN 70 1 9 $PLINEGEN 70 0 9 $PSLTSCALE 70 1 0 ENDSEC 0 SECTION 2 TABLES 0 TABLE 2 VPORT 70 1 0 ENDTAB 0 TABLE 2 LTYPE 70 3 0 LTYPE 2 CONTINUOUS 70 0 3 Solidline 72 65 73 0 40 0.0 0 LTYPE 2 ACAD_ISO04W100 70 0 3 ISOlong-dashdot____.____.____.____._ 72 65 73 4 40 2.0 49 1.399999999999999 49 -0.3 49 0.0 49 -0.3 0 LTYPE 2 ACAD_ISO02W100 70 0 3 ISOdash__________________________ 72 65 73 2 40 15.0 49 12.0 49 -3.0 0 ENDTAB 0 TABLE 2 LAYER 70 16 0 LAYER 2 0 70 0 62 7 6 CONTINUOUS 0 LAYER 2 DEFPOINTS 70 0 62 7 6 CONTINUOUS 0 LAYER 2 PIPE 70 0 62 6 6 CONTINUOUS 0 LAYER 2 GRID 70 0 62 8 6 CONTINUOUS 0 LAYER 2 GROUND 70 0 62 3 6 CONTINUOUS 0 LAYER 2 POINTID 70 0 62 1 6 CONTINUOUS 0 LAYER 2 ELEVATION 70 0 62 1 6 CONTINUOUS 0 LAYER 2 POINTS 70 0 62 6 6 CONTINUOUS 0 LAYER 2 X-Y-CORDS 70 0 62 6 6 CONTINUOUS 0 LAYER 2 NOTES 70 0 62 4 6 CONTINUOUS 0 LAYER 2 LATERAL 70 0 62 4 6 CONTINUOUS 0 LAYER 2 LATERALG 70 0 62 3 6 CONTINUOUS 0 LAYER 2 3DPOLY 70 0 62 5 6 CONTINUOUS 0 LAYER 2 HATCH 70 0 62 9 6 CONTINUOUS 0 LAYER 2 TEXT 70 0 62 7 6 CONTINUOUS 0 LAYER 2 DIMENSIONS 70 0 62 5 6 CONTINUOUS 0 LAYER 2 TABLES 70 0 62 7 6 CONTINUOUS 0 LAYER 2 MANHOLE 70 0 62 1 6 CONTINUOUS 0 LAYER 2 HIDDEN 70 0 62 7 6 ACAD_ISO02W100 0 LAYER 2 GV 70 0 62 5 6 CONTINUOUS 0 LAYER 2 FH 70 0 62 1 6 CONTINUOUS 0 LAYER 2 SL 70 0 62 5 6 CONTINUOUS 0 LAYER 2 PI 70 0 62 6 6 CONTINUOUS 0 LAYER 2 TR 70 0 62 1 6 CONTINUOUS 0 LAYER 2 HC 70 0 62 5 6 CONTINUOUS 0 LAYER 2 MH 70 0 62 1 6 CONTINUOUS 0 LAYER 2 Y 70 0 62 7 6 CONTINUOUS 0 ENDTAB 0 TABLE 2 STYLE 70 4 0 STYLE 2 STANDARD 70 0 40 0.15 41 1.0 50 0.0 71 0 42 0.15 3 txt.shx 4 0 STYLE 2 ANNOTATIVE 70 0 40 0.0 41 1.0 50 0.0 71 0 42 0.2 3 txt 4 0 STYLE 2 LOCAL 70 0 40 0.15 41 1.0 50 0.0 71 0 42 0.15 3 x-arab.shx 4 0 STYLE 2 70 1 40 0.0 41 1.0 50 0.0 71 0 42 2.5 3 ltypeshp.shx 4 0 ENDTAB 0 TABLE 2 VIEW 70 0 0 ENDTAB 0 TABLE 2 UCS 70 0 0 ENDTAB 0 TABLE 2 APPID 70 12 0 APPID 2 ACAD 70 0 0 APPID 2 ACADANNOTATIVE 70 0 0 APPID 2 ACAECLAYERSTANDARD 70 0 0 APPID 2 ACCMTRANSPARENCY 70 0 0 APPID 2 ACAD_EXEMPT_FROM_CAD_STANDARDS 70 0 0 APPID 2 ACAD_DSTYLE_DIMJAG 70 0 0 APPID 2 ACAD_DSTYLE_DIMBREAK 70 0 0 APPID 2 ACAD_DSTYLE_DIMTALN 70 0 0 APPID 2 ACADANNOPO 70 0 0 APPID 2 ACAD_DSTYLE_DIMJOGGED_JOGA 70 0 0 APPID 2 ACAD_DSTYLE_DIMTEXT_FILL 70 0 0 APPID 2 ACAD_MLEADERVER 70 0 0 ENDTAB 0 TABLE 2 DIMSTYLE 70 3 0 DIMSTYLE 2 STANDARD 70 0 3 4 5 6 7 40 1.0 41 0.18 42 0.0625 43 0.38 44 0.18 45 0.0 46 0.0 47 0.0 48 0.0 140 0.18 141 0.09 142 0.0 143 25.399999999999999 144 1.0 145 0.0 146 1.0 147 0.09 71 0 72 0 73 1 74 1 75 0 76 0 77 0 78 0 170 0 171 2 172 0 173 0 174 0 175 0 176 0 177 0 178 0 0 DIMSTYLE 2 ANNOTATIVE 70 0 3 4 5 6 7 40 1.0 41 0.18 42 0.0625 43 0.38 44 0.18 45 0.0 46 0.0 47 0.0 48 0.0 140 0.18 141 0.09 142 0.0 143 25.399999999999999 144 1.0 145 0.0 146 1.0 147 0.09 71 0 72 0 73 1 74 1 75 0 76 0 77 0 78 0 170 0 171 2 172 0 173 0 174 0 175 0 176 0 177 0 178 0 0 DIMSTYLE 2 ISO-25 70 0 3 4 5 6 7 40 1.0 41 0.1 42 0.25 43 0.25 44 0.1 45 0.0 46 0.0 47 0.0 48 0.0 140 0.15 141 0.1 142 0.0 143 0.03937007874016 144 1.0 145 0.0 146 1.0 147 0.15 71 0 72 0 73 0 74 1 75 0 76 0 77 1 78 8 170 0 171 3 172 1 173 0 174 0 175 0 176 2 177 0 178 7 0 ENDTAB 0 ENDSEC 0 SECTION 2 BLOCKS 0 BLOCK 8 POINTS 2 Block0 70 0 10 0 20 0 30 0 3 Block0 1 0 SOLID 5 100004 8 POINTS 10 678218.2191 20 2717042.676 30 0 11 678220.4691 21 2717042.676 31 0 12 678218.2191 22 2717040.426 32 0 13 678220.4691 23 2717040.426 33 0 39 1 210 0 220 0 230 1 0 TEXT 5 100005 8 POINTS 10 678221.5941 20 2717043.801 30 0 11 678221.5941 21 2717043.801 31 0 72 0 73 1 40 2.25 1 point 50 0 7 STANDARD 0 ENDBLK 5 100002 8 POINTS 0 BLOCK 8 0 2 $MODEL_SPACE 70 0 10 0.0 20 0.0 30 0.0 3 $MODEL_SPACE 1 0 ENDBLK 5 10 8 0 0 BLOCK 67 1 8 0 2 $PAPER_SPACE 70 0 10 0.0 20 0.0 30 0.0 3 $PAPER_SPACE 1 0 ENDBLK 5 11 67 1 8 0 0 ENDSEC 0 SECTION 2 ENTITIES 0 POINT 5 100003 8 POINTS 10 678219.3441 20 2717041.551 30 0 0 INSERT 5 100001 8 POINTS 2 Block0 10 0 20 0 30 0 0 ENDSEC 0 EOF
imagemagick - find coordinates of outline of transparent png (not border)
While it's easily done to visually outline, is it possible to have imagemagick output the coordinates of the outline of a transparent image? Note, by outline, I don't mean just the bounding box border, but the actual contour around an arbitrarily shaped transparent image geometry.
Let's say you start with this image, which has a transparent background: You can extract the transparency and find the edges like this: convert penguin.png -alpha extract -edge 1 -threshold 50% edges.png If, rather than an image, you want a list of the coordinates of the contour (i.e. the white pixels), you could do this instead: convert penguin.png -alpha extract -edge 1 -threshold 50% -depth 8 txt: | awk -F: '/white/{print $1}' 256,0 253,1 254,1 255,1 257,1 258,1 259,1 253,2 259,2 252,3 253,3 ... ... Replace awk and everything after it with more to see what the awk is actually doing - it is just printing the coordinates of every pixel that is white. The above pixels come out in row order, not like a contour where adjacent pixels come out together. If you want that, you might prefer to generate an SVG of the transparency with potrace like this: convert penguin.png -alpha extract -threshold 50% pgm:- | potrace - --svg < alpha.pgm > result.svg Output <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="500.000000pt" height="577.000000pt" viewBox="0 0 500.000000 577.000000" preserveAspectRatio="xMidYMid meet"> <metadata> Created by potrace 1.13, written by Peter Selinger 2001-2015 </metadata> <g transform="translate(0.000000,577.000000) scale(0.100000,-0.100000)" fill="#000000" stroke="none"> <path d="M0 3294 l0 -2476 25 16 c31 20 104 21 152 1 20 -8 38 -14 40 -12 2 2 -8 35 -23 73 -49 129 -29 246 43 260 51 10 109 -12 159 -58 43 -40 44 -40 44 -15 0 41 60 120 99 130 28 7 32 11 26 30 -24 70 -15 385 16 637 44 346 171 715 351 1023 34 58 35 77 5 77 -43 0 -242 47 -277 65 -68 35 -196 130 -248 185 -83 86 -119 154 -153 286 -31 124 -38 237 -18 307 13 49 15 49 91 -15 177 -151 388 -309 477 -357 42 -23 108 -60 146 -81 76 -43 194 -83 228 -78 19 3 23 12 28 60 4 32 12 65 19 73 15 18 16 17 -35 34 -88 29 -255 122 -255 141 0 5 12 15 27 22 24 11 48 10 168 -9 77 -12 179 -22 226 -23 80 0 87 2 111 28 60 64 64 105 11 123 -21 6 -76 30 -122 51 l-84 39 -30 -21 c-21 -16 -32 -19 -40 -11 -19 19 8 54 63 84 46 25 59 27 109 22 31 -3 66 -8 79 -11 77 -16 -65 130 -178 182 -84 38 -150 45 -340 35 -225 -12 -242 -15 -322 -55 -57 -28 -68 -31 -68 -17 0 26 77 95 150 134 206 112 479 177 741 177 l97 0 -20 38 c-37 70 -10 186 68 294 54 75 56 88 23 119 -16 15 -29 36 -29 47 0 12 -4 24 -10 27 -19 12 -10 57 18 94 69 89 125 236 167 431 24 113 41 148 68 137 19 -7 43 -83 52 -162 l7 -60 33 90 c18 50 36 110 40 135 10 61 55 111 55 61 0 -11 9 -35 20 -54 29 -49 40 -235 17 -289 -9 -21 -12 -38 -8 -38 4 0 34 22 65 50 31 27 66 55 78 61 20 11 21 9 14 -22 -3 -18 -24 -72 -46 -119 -22 -48 -40 -90 -40 -94 0 -14 43 17 110 80 143 136 324 456 306 545 -4 21 -1 31 12 38 11 7 -402 10 -1260 11 l-1278 0 0 -2476z"/> <path d="M2613 5669 c17 -82 18 -107 9 -133 -7 -18 -12 -47 -12 -64 0 -18 -14 -60 -31 -93 -17 -34 -28 -64 -25 -67 10 -10 49 17 129 88 43 39 84 70 92 70 23 0 17 -31 -15 -79 -17 -24 -30 -49 -30 -56 0 -6 -32 -58 -70 -115 -39 -56 -69 -104 -67 -106 4 -5 111 33 153 54 33 17 42 18 57 7 9 -7 17 -17 17 -23 0 -16 -104 -125 -134 -141 -14 -8 -26 -17 -26 -20 0 -4 23 -17 50 -30 53 -25 100 -63 100 -80 0 -19 -36 -30 -116 -36 -43 -3 -103 -8 -133 -11 l-54 -6 82 -80 c92 -90 185 -225 230 -331 34 -83 71 -217 71 -260 0 -15 5 -38 12 -50 18 -34 31 -169 29 -311 -1 -97 2 -133 12 -145 8 -9 29 -43 47 -76 19 -33 58 -96 87 -139 64 -93 107 -175 122 -233 10 -36 17 -44 49 -54 59 -18 220 -22 467 -9 127 6 316 15 420 20 184 9 267 15 311 25 46 10 364 35 451 35 64 0 93 -4 96 -12 3 -7 6 566 6 1275 l1 1287 -1204 0 -1203 0 20 -101z"/> <path d="M4971 3138 c-20 -33 -89 -96 -165 -153 -23 -17 -103 -92 -179 -168 -77 -75 -145 -137 -153 -137 -8 0 -27 -21 -43 -47 -29 -47 -30 -47 -178 -99 -81 -29 -158 -53 -171 -53 -12 -1 -61 -15 -109 -31 -50 -18 -106 -30 -133 -30 -25 1 -101 -2 -170 -6 -100 -5 -136 -3 -179 10 -30 9 -70 16 -89 16 -33 0 -33 -1 -25 -32 4 -18 8 -92 8 -164 l0 -132 32 -20 c17 -12 70 -64 117 -117 68 -76 96 -119 140 -208 58 -118 106 -256 106 -302 0 -24 3 -26 23 -20 12 3 42 9 67 12 69 8 83 -18 98 -180 16 -176 45 -309 96 -446 24 -64 48 -129 54 -146 17 -50 52 -247 52 -295 0 -69 -42 -141 -129 -221 -99 -91 -141 -111 -239 -112 -91 -2 -129 14 -157 67 -23 42 -35 44 -76 14 -35 -26 -138 -36 -191 -19 -60 20 -78 45 -78 106 0 47 4 57 24 70 41 27 148 62 227 74 41 6 89 14 107 17 19 3 32 11 32 20 0 8 12 42 26 75 24 58 25 66 15 145 -7 57 -25 120 -57 204 -26 66 -50 120 -53 120 -16 -1 -49 -42 -73 -90 -56 -110 -125 -182 -277 -287 -66 -46 -158 -73 -248 -73 -82 0 -93 -4 -173 -65 -85 -65 -188 -116 -290 -143 -139 -38 -226 -46 -470 -45 -201 1 -250 4 -339 23 -57 12 -116 20 -130 17 -14 -3 -73 -22 -131 -42 -97 -34 -111 -37 -192 -33 l-87 4 -6 -40 c-4 -23 -9 -55 -12 -73 -7 -43 -51 -82 -104 -92 -25 -5 786 -9 1934 -10 l1977 -1 0 1585 c0 872 -2 1585 -4 1585 -2 0 -14 -15 -25 -32z"/> <path d="M0 358 l0 -358 458 1 c393 1 450 2 407 14 -146 37 -255 105 -435 270 -30 28 -102 83 -160 122 -173 118 -218 166 -256 271 -11 32 -13 -14 -14 -320z"/> </g> </svg>
Assuming you have a transparent "input.png", first convert all nontransparent pixels to white, then use the "-edge" option to find the transitions between transparent and white: convert input.png -negate -threshold 1 -edge 1 edge.png Note that this will not only outline the image but will outline any "holes" in it as well. For example, try it with the built-in "logo:" image: convert logo: -transparent white logotrans.png convert logotrans.png -negate -threshold 1 -edge 1 t.png which transforms this to this
Defining attributes with .arff file in Weka
I have a problem in Weka library.I am trying to convert txt file to .arff file.But I got some error.My txt file like below: Atlanta.txt 0000000 Tanner's 100 253 250 178 174 063 059 036 008 074 204 052 163 0000001 Frijoleros 250 062 132 174 063 197 071 142 234 243 075 204 052 162 0000002 Indian Delights 253 250 150 174 083 059 036 117 243 076 205 051 162 0000003 Great Wall 253 191 192 174 036 039 075 204 052 163 0000004 The Brickery 100 253 086 231 250 191 192 059 036 215 005 008 075 205 052 163 0000005 Lawrence's Cafe 250 191 192 174 063 197 071 057 036 140 143 075 204 052 163 0000006 Harold's Barbecue 253 174 010 221 036 017 076 205 051 162 0000007 Zab-E-Lee 011 174 235 076 208 051 164 0000008 The Dessert Place 100 086 150 174 036 042 061 076 204 053 162 0000009 Cafe Diem 250 196 174 063 197 005 042 061 068 074 204 053 162 0000010 El Charro 100 253 250 191 192 174 001 142 234 075 204 051 162 0000011 Kurt's at River Manor 253 231 191 192 174 063 248 036 098 076 205 054 165 0000012 Peggy Sue's Diner 100 253 086 250 191 192 174 063 036 042 061 074 204 053 163 0000013 Pars 253 250 174 071 059 057 036 143 075 205 053 164 0000014 Le Rendez-Vous 253 231 250 200 191 192 174 059 036 091 076 205 053 164 0000015 Rockbridge Diner 253 231 136 191 192 059 045 076 206 053 164 0000016 Chefs' Grill 100 080 253 231 102 191 192 174 083 036 024 025 005 076 206 053 165 0000017 Jonathan Lee's 253 231 245 191 192 174 059 036 039 235 075 205 052 163 0000018 The Country Place 253 099 231 250 062 132 191 192 174 071 083 024 215 005 076 206 054 165 0000019 Hama's 253 250 245 174 128 075 205 052 164 0000020 Raja Indian Restaurant 250 191 192 174 197 036 117 075 205 051 164 0000021 PRICCI 080 253 250 245 189 102 174 114 024 215 121 076 206 054 166 0000022 Pittypat's Porch 100 253 099 250 191 192 174 071 221 083 024 220 217 074 204 052 165 0000023 Houston's 026 253 086 250 174 063 215 005 008 107 076 206 053 164 0000024 Azio 253 086 231 250 102 063 114 248 215 121 182 075 205 053 164 0000026 ABRUZZI RISTORANTE 253 099 200 245 196 189 191 192 174 146 097 036 024 123 076 206 053 167 0000027 Rio Bravo Cantina 100 253 086 250 191 192 174 063 215 138 142 234 075 205 053 163 0000028 Savannah Fish Company 250 191 192 174 040 025 212 075 205 053 165 0000029 Lombardi's 253 231 250 174 024 121 075 205 053 164 0000030 Johnny Rockets 026 100 086 250 174 063 008 107 075 205 053 162 0000031 Opus 099 150 200 196 191 192 174 063 040 071 024 025 005 243 076 206 054 167 0000032 La Paz 100 253 250 191 192 174 063 197 083 036 215 025 142 234 222 076 205 053 163 I need to attribute value as Restaurant Id,Restaurant Name,Cuisine,Price,Style,Atmosphere and Occasion(Restaurant Features).But as you can see,number of columns and number of attributes don't exactly match each other.How can i delete some noise data and how can i group all of these features in this situation.I am planning to make a .arff file like that: Atlanta.arff #RELATION 'Atlanta' #ATTRIBUTE Restaurant Id NUMERIC #ATTRIBUTE Restaurant Name String #ATTRIBUTE Restaurant Features NUMERIC #DATA 0000000 Tanner's {100 253 250 178 174 063 059 036 008 074 204 052 163} 0000001 Frijoleros {250 062 132 174 063 197 071 142 234 243 075 204 052 162} 0000002 Indian Delights {253 250 150 174 083 059 036 117 243 076 205 051 162} 0000003 Great Wall {253 191 192 174 036 039 075 204 052 163} 0000004 The Brickery {100 253 086 231 250 191 192 059 036 215 005 008 075 205 052 163} 0000005 Lawrence's Cafe {250 191 192 174 063 197 071 057 036 140 143 075 204 052 163} 0000006 Harold's Barbecue {253 174 010 221 036 017 076 205 051 162} 0000007 Zab-E-Lee {011 174 235 076 208 051 164} 0000008 The Dessert Place {100 086 150 174 036 042 061 076 204 053 162} 0000009 Cafe Diem {250 196 174 063 197 005 042 061 068 074 204 053 162} 0000010 El Charro {100 253 250 191 192 174 001 142 234 075 204 051 162} 0000011 Kurt's at River Manor {253 231 191 192 174 063 248 036 098 076 205 054 165} 0000012 Peggy Sue's Diner {100 253 086 250 191 192 174 063 036 042 061 074 204 053 163} 0000013 Pars {253 250 174 071 059 057 036 143 075 205 053 164} 0000014 Le Rendez-Vous {253 231 250 200 191 192 174 059 036 091 076 205 053 164} 0000015 Rockbridge Diner {253 231 136 191 192 059 045 076 206 053 164} 0000016 Chefs' Grill {100 080 253 231 102 191 192 174 083 036 024 025 005 076 206 053 165} 0000017 Jonathan Lee's {253 231 245 191 192 174 059 036 039 235 075 205 052 163} 0000018 The Country Place {253 099 231 250 062 132 191 192 174 071 083 024 215 005 076 206 054 165} 0000019 Hama's {253 250 245 174 128 075 205 052 164} 0000020 Raja Indian Restaurant {250 191 192 174 197 036 117 075 205 051 164} 0000021 PRICCI {080 253 250 245 189 102 174 114 024 215 121 076 206 054 166} 0000022 Pittypat's Porch {100 253 099 250 191 192 174 071 221 083 024 220 217 074 204 052 165} 0000023 Houston's {026 253 086 250 174 063 215 005 008 107 076 206 053 164} 0000024 Azio {253 086 231 250 102 063 114 248 215 121 182 075 205 053 164} 0000025 Banks {136 005 045 076 206 054 166} 0000026 ABRUZZI RISTORANTE {253 099 200 245 196 189 191 192 174 146 097 036 024 123 076 206 053 167} 0000027 Rio Bravo Cantina {100 253 086 250 191 192 174 063 215 138 142 234 075 205 053 163} 0000028 Savannah Fish Company {250 191 192 174 040 025 212 075 205 053 165} 0000029 Lombardi's {253 231 250 174 024 121 075 205 053 164} 0000030 Johnny Rockets {026 100 086 250 174 063 008 107 075 205 053 162} 0000031 Opus {099 150 200 196 191 192 174 063 040 071 024 025 005 243 076 206 054 167} 0000032 La Paz {100 253 250 191 192 174 063 197 083 036 215 025 142 234 222 076 205 053 163} Thank you for your helping.Happy coding:)
If you are using the Weka GUI, I would recommend the following: Open your data file in Excel (import the data as tab separated values) Add the headers you want, and fill in missing data. Every row must have all column values filled in for Weka to read the data properly. Save your file as a .csv Open the Weka GUI, go to Explorer, then Open file, set the format as csv (see image), and open the csv file you just saved. After you've loaded your data, you can save it to arff using the Save... button.
parsing using awk
how to parse a file based on data from another file using awk. i made a script: BEGIN{ FS="\t" ; OFS="\t" while((getline<"headfpkm")>0) { ++a id[a]=$1 fpkm[a]=$2 print id[a],fpkm[a] } lastid=id[a] print lastid close("headfpkm") } /$lastid/{ print $2,$3,$5,$7,$8,$14,fpkm[a] a-- lastid=id[a] } END{ print "total lines=",FNR,"\n\nfile 1 index: ",a} when i run it : /$ awk -f testawk.awk file2 it runs the BEGIN section properly but doesnt give any output. NM_000014 5.04503 NM_000015 0.586677 NM_000016 1.138332278 NM_000017 0.64386 NM_000018 3.61746 NM_000019 2.8793 NM_000020 10.846 NM_000021 0.685098 NM_000022 46388.6 NM_000026 0.257471 NM_000026 total lines= 10 file 1 index: 10 Is anything wrong with the searching section?? file 2 looks like this: 34 ACADM NM_000016 9606 hsa-miR-3148 3 80 87 0.003 -0.016 -0.094 0.082 0.112 -0.160 97 34 ACADM NM_000016 9606 hsa-miR-3163 1 623 629 0.001 -0.022 -0.020 0.065 0.125 -0.01 57 35 ACADS NM_000017 9606 hsa-miR-3921 3 68 75 0.013 0.192 -0.097 0.031 -0.039 -0.147 82 35 ACADS NM_000017 9606 hsa-miR-4303 2 67 73 0.012 0.150 -0.052 0.013 -0.039 -0.036 31 35 ACADS NM_000017 9606 hsa-miR-4653-5p 3 68 75 0.003 0.192 -0.097 0.031 -0.039 -0.157 84 37 ACADVL NM_000018 9606 hsa-miR-124 2 31 37 0.003 0.023 -0.057 0.012 -0.032 -0.171 76 37 ACADVL NM_000018 9606 hsa-miR-1827 2 135 141 -0.007 -0.043 -0.058 0.039 -0.069 -0.258 91 37 ACADVL NM_000018 9606 hsa-miR-2682 2 134 140 0.003 -0.014 -0.058 0.004 -0.047 -0.232 87 37 ACADVL NM_000018 9606 hsa-miR-449c 2 134 140 -0.035 -0.014 -0.058 0.004 -0.047 -0.270 92 37 ACADVL NM_000018 9606 hsa-miR-506 2 31 37 -0.016 0.023 -0.057 0.012 -0.032 -0.190 80
This is going to be a bit of guess, because I'm not 100% sure as to what you're trying to accomplish. The better way to solve your problem, would be to do something like this: BEGIN { FS=OFS="\t" } FNR==NR { c++ a[$1]=$2 next } $3 in a { print $2,$3,$5,$7,$8,$14,a[$3] } END { printf "total lines=%s\n\nfile 1 index: %s\n", FNR, c } Run like: awk -f script.awk headfpkm file2 Results: ACADM NM_000016 hsa-miR-3148 80 87 -0.160 1.138332278 ACADM NM_000016 hsa-miR-3163 623 629 -0.01 1.138332278 ACADS NM_000017 hsa-miR-3921 68 75 -0.147 0.64386 ACADS NM_000017 hsa-miR-4303 67 73 -0.036 0.64386 ACADS NM_000017 hsa-miR-4653-5p 68 75 -0.157 0.64386 ACADVL NM_000018 hsa-miR-124 31 37 -0.171 3.61746 ACADVL NM_000018 hsa-miR-1827 135 141 -0.258 3.61746 ACADVL NM_000018 hsa-miR-2682 134 140 -0.232 3.61746 ACADVL NM_000018 hsa-miR-449c 134 140 -0.270 3.61746 ACADVL NM_000018 hsa-miR-506 31 37 -0.190 3.61746 total lines=10 file 1 index: 10