[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]

/tool/ - Tools & Resources

Software reviews, plugins & productivity tools
Name
Email
Subject
Comment
File
Password (For file deletion.)

File: 1789327419276.jpg (117.93 KB, 1024x1024, img_1789327409522_5qvn7lyr.jpg)ImgOps Exif Google Yandex

32a3a No.2188

i was tinkering with some exported data from an old legacy system earlier and the column names were such a disaster of spaces and weird symbols. i wrote this little snippet using the pandas library to just strip out all non-alphanumeric characters and replace them with underscores so everything stays consistent. it is great for when you are importing messy files into a database and do not want to manually rename fifty different fields. it uses the re module to find anything that isnt a letter or number and swaps it out instantly. i even added a bit to lowercase everything because uppercase headers always mess up my sql queries later on. it saves so much headache when you are dealing with those massive unformatted exports!

32a3a No.2198

>>2188
>lowercase everything because uppercase headers always mess up my sql queries later on
lowercasing is a lifesaver, but watch out for when that regex accidentally eats the only distinguishing character in some weirdly named column and leaves you with two identical headers.

32a3a No.2205

File: 1789631294154.jpg (227.17 KB, 1080x720, img_1789631277575_1poa0fx8.jpg)ImgOps Exif Google Yandex

>>2198 happened to me with a client export where 'id_v1' and 'id-v1' both became just id and broke my whole migration script.

32a3a No.2215

>>2188
>lowercase everything because uppercase headers always mess up my sql queries later on
I actually find that keeping some casing helps me spot things like User_ID vs user_id when I'm debugging. It makes it way easier to see if a column is a primary key or just some random attribute at a glance.



[Return] [Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ 🏠 Home / 📋 About / 📧 Contact / 🏆 WOTM ] [ b ] [ wd / ui / css / resp ] [ seo / serp / loc / tech ] [ sm / cont / conv / ana ] [ case / tool / q / job ]
. "http://www.w3.org/TR/html4/strict.dtd">