Streamlining Guidance Request

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Kelly
Posts: 34
Joined: Sat May 28, 2011 8:59 am
Location: Ellsworth, ME

Streamlining Guidance Request

Post by Kelly »

Hello,
My regex powers are mediocre on good days. I've manged to accomplish what I need to do one step at a time, but the repeated chore makes me wonder if the process might be streamlined. I'm not asking for somebody to do the work for me, but rather I'm hoping for guidance on the best approach to consolidate my one-step-at-a-time formula - see my steps noted below. The gist of it is to take the portion of a Global Mapper Pixels to Points HTML report showing final adjusted camera locations (table) and convert it into a tab delimited format.
Thanks very much for any thoughts.
Kelly

Code: Select all

3:33 AM   Thursday, August 18, 2022  (VKB)
Final Camera Locations HTML Wrangle for TextPad & RegEx

Beginning with P2P's Pixels to Points Processing Report.htm open in browser
Ctrl+u to show html source
Locate table beginning with
<tbody><tr>
		<th>Filename</th>
		<th>Latitude</th>
		<th>Longitude</th>
		<th>Elevation</th>
		<th>Roll</th>
		<th>Pitch</th>
		<th>Yaw</th>
	</tr>
	
Then copy everything beneath it until the end of the table
</tr>
</tbody></table><br>

Paste into new TextPad document and begin cleanup

Replace with nothing
\t
<td align="left">
<td align="center">
<td align="right">
°
 m
 N
 W

Replace ^69 with -69 (or whatever your longitude)

Replace </td>\n with \t 

Replace <tr>\n with nothing

Replace </tr>\n with \n
 

Doing this last bit will allow loading text file into Global Mapper (Y/Northing first)

Column cut DJI_0000 and paste at end of last tab

Replace ^\t with nothing

Insert column header row
Latitude	Longitude	Elevation	Roll	Pitch	Yaw	Filename

When you're done, should look smoething like
Latitude	Longitude	Elevation	Roll	Pitch	Yaw	Filename
44.9521476511	-69.1742673904	36.144	0.000	-86.960	175.866	DJI_0090
44.9520710267	-69.1742679789	36.810	0.000	-87.283	177.629	DJI_0091
44.9520062489	-69.1742633697	36.983	0.000	-87.593	177.971	DJI_0092
44.9519419705	-69.1742591335	36.745	0.000	-87.938	178.182	DJI_0093
44.9518775907	-69.1742574740	36.776	0.000	-88.267	177.975	DJI_0094
ak47wong
Posts: 703
Joined: Tue Aug 12, 2003 9:37 am
Location: Sydney, Australia

Post by ak47wong »

It would be useful to see the actual HTML code. Could you post the code for the table containing the five rows in your example? I'd suggest using the code tags for just the HTML code, not for explanatory text.
Kelly
Posts: 34
Joined: Sat May 28, 2011 8:59 am
Location: Ellsworth, ME

Post by Kelly »

Thank you for the reply. Here's a snip from one of the html reports; the table structure is the same, but the cell values may be different.

Code: Select all

<tr>
		<th>Filename</th>
		<th>Latitude</th>
		<th>Longitude</th>
		<th>Elevation</th>
		<th>Roll</th>
		<th>Pitch</th>
		<th>Yaw</th>
	</tr>
	<tr>
		<td align="left">DJI_0090</td>
		<td align="center">44.9521102238° N</td>
		<td align="center">69.1742891866° W</td>
		<td align="right">138.043 m</td>
		<td align="center">0.000°</td>
		<td align="center">-88.421°</td>
		<td align="center">175.320°</td>
	</tr>
	<tr>
		<td align="left">DJI_0091</td>
		<td align="center">44.9520356514° N</td>
		<td align="center">69.1742897255° W</td>
		<td align="right">138.825 m</td>
		<td align="center">0.000°</td>
		<td align="center">-88.337°</td>
		<td align="center">177.002°</td>
	</tr>
	<tr>
		<td align="left">DJI_0092</td>
		<td align="center">44.9519711905° N</td>
		<td align="center">69.1742845994° W</td>
		<td align="right">139.085 m</td>
		<td align="center">0.000°</td>
		<td align="center">-88.439°</td>
		<td align="center">177.344°</td>
	</tr>
	<tr>
		<td align="left">DJI_0093</td>
		<td align="center">44.9519077296° N</td>
		<td align="center">69.1742793067° W</td>
		<td align="right">138.915 m</td>
		<td align="center">0.000°</td>
		<td align="center">-88.750°</td>
		<td align="center">177.557°</td>
	</tr>
	<tr>
		<td align="left">DJI_0094</td>
		<td align="center">44.9518439536° N</td>
		<td align="center">69.1742766132° W</td>
		<td align="right">138.999 m</td>
		<td align="center">0.000°</td>
		<td align="center">-89.101°</td>
		<td align="center">177.373°</td>
	</tr>
User avatar
AmigoJack
Posts: 532
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

  1. TextPad > Macros > Record (Ctrl+Shift+R)
  2. TextPad > Search > Replace (F8)
  3. Find:

    Code: Select all

    \s*<td[^>]*>([^< ]+)</td>\n\s*<td[^>]*>([^< ]+)° ?[NS]</td>\n\s*<td[^>]*>([^< ]+)° ?[EW]</td>\n\s*<td[^>]*>([^< ]+) ?m</td>\n\s*<td[^>]*>([^< ]+)°</td>\n\s*<td[^>]*>([^< ]+)°</td>\n\s*<td[^>]*>([^< ]+)°</td>
    Replace with:

    Code: Select all

    \2\t\3\t\4\t\5\t\6\t\7\t\1
  4. Do other stuff, like the heading
  5. TextPad > Macros > Stop recording (Ctrl+Shift+R)
  6. Save macro and use it again as often you want for other files
As per "replace with" you can figure out that the "find" regex just captures all 7 columns at once, avoiding spaces and the opening tag. Record it once as macro, then just playback the macro when needed again.
Kelly
Posts: 34
Joined: Sat May 28, 2011 8:59 am
Location: Ellsworth, ME

Post by Kelly »

Oh my gosh! Thank you AmigoJack for doing this work, and by way of this instructive example introducing me to \s together with F8 and making a macro!! I will need to study/ dissect this with the TextPad Help section open to Replacement Format Strings.

Thanks again and I'll let you know how this turns out! I very much appreciate the help! - Kelly
Kelly
Posts: 34
Joined: Sat May 28, 2011 8:59 am
Location: Ellsworth, ME

Post by Kelly »

AmigoJack, I did the other stuff which included cleaning up the html row codes, and entering the header stuff while recording the macro, and in the order of operations as you outlined. Works great! Thanks again for all of your greatly appreciated help!
User avatar
AmigoJack
Posts: 532
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

You're welcome. :)

If you want to dive into regular expressions (a topic that TextPad's help can't fully cover) then nowadays https://www.regular-expressions.info/quickstart.html is very worth to be read from top to bottom, either to always look it up again when you need it, or to use as a base to then hit chosen "Tutorial" pages, selecting from dozens of specific topics those you feel confident enough to grow your understanding of it even more.

\s is covered in Tutorial > Shorthand Character Classes.
Kelly
Posts: 34
Joined: Sat May 28, 2011 8:59 am
Location: Ellsworth, ME

Post by Kelly »

Thank you AmigoJack for the instructive next step. I will try that site again but now in retirement, with more earnestness and time than I had 9 years ago. After finding Jan Goyvaets's site in 2013, I bought the book https://www.regular-expressions.info/hipowls.html. I never made it past the first 2 chapters. For now, I'll just try and apply myself to what you've outlined and keep the book by Jeffrey Fiedl on the shelf :)
Post Reply