My progress as a stupid programmer

In development of GIS application, even a stupid one like my assignment, we cannot avoid manipulating the spreadsheet (yeah. The most important element of GIS is the spreadsheet, not the graphic part; and yeah. Somebody may use a grandeurer term to describe it –database.  But it’s still just a spreadsheet). That’s where I understand how stupid I am as a programmer; even how stupid I am, as an Arts student for over 30 years, to try to be a programmer (even in short while).

I have a spreadsheet of Household units no. assigned row by row according to the Census tract id.  For a couple of reasons (usually down to laziness), household census data of several census tract ids are grouped together as a single entity. For example,

[ ID1 : 100; ID2: 9; ID3: 5] becomes [ID1&ID2&ID3: 114]

My groupmate (actually no groupmate, just somebody) helped me breakdown those combined morons back to separate IDs again (ID1&ID2&ID3 back to ID1; ID2; ID3) in a new spreadsheet for my convenience. But, for a couple of reasons (I think also about laziness), they didn’t change the Household data. That created 3 morons:

[ID1: 114; ID1: I114; ID1: 114]

I can’t use Apple throw table emoji here on my laptop. I definite would use it if I had !

I need to divide that 114 by number of ID with such stupid assigned value.  But like for a whole spreadsheet of many those moron^2s. I can use calculator to do it one at a time. (After all, calculator is still a computer. No rules been violated) But as a programmer, it doesn’t sound cool. So I need some manipulation script for my task.


I searched online for Python List function. Try to put the IDs to the list row by row. And use a lot of steps, and nights, and rounds of trial and errors, to simulate just a simple step in Excel (the best spreadsheet manipulator so far in history), as follows:

B1 = 0

B2 = A1

Then drag my mouse down to the last row of B column.


And it doesn’t work. All in vain for my many steps, many searches, many rounds of trial and errors. Because in ESRI ArcGIS python, row in fact means column.

Finger Straight (middle)

Finally, I found out that I just need a simple SQL script to sort out all IDs with that fucking symbol “&".

The final script that works is this:

whereclause = ‘"Field1″ Like \’%&%\"
upcur = arcpy.da.UpdateCursor(“TPU_pop_2018_2″,[“SAME"],whereclause)
for row in upcur:
… row[0] = 1
… upcur.updateRow(row)

whereclause2 = ‘"SAME" > 1’
upcur2 = arcpy.da.UpdateCursor(“TPU_pop_2018_2″,[“SAME"],whereclause2)
for row2 in upcur2:
… row2[0] = 0
… upcur2.updateRow(row2)
del row, row2, upcur, upcur2
del whereclause, whereclause2

The above script in fact cannot reach my final goal of automatic division of those stupid assigned values by the number of occurances of same IDs. There’s still some way to go.

That’s how stupid I am as a programmer.

I always say programming is like making something with Lego.

True. Except that I am a duplo player being given Technic series blocs. And some pirated version of the instruction to build a boat. And my teacher wants me to build a boat.

FingerStraight(Middle; 2 hands)

In straight time, have some cool stuff mate:

Mary J. Blige

Hope y’all doing just fine.


在下方填入你的資料或按右方圖示以社群網站登入: 標誌

您的留言將使用 帳號。 登出 /  變更 )

Google photo

您的留言將使用 Google 帳號。 登出 /  變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 /  變更 )


您的留言將使用 Facebook 帳號。 登出 /  變更 )

連結到 %s

%d 位部落客按了讚:
search previous next tag category expand menu location phone mail time cart zoom edit close