- Podcasts
- CyberSecurity Summary
- Data Wrangling with JavaScript
About this episodeA comprehensive guide for JavaScript developers to acquire, clean, and analyze data without needing to switch to other programming…
You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cyber_security_summary
Get the Book now from Amazon:
https://www.amazon.com/Data-Wrangling-JavaScript-Ashley-Davis/dp/1617294845?&linkCode=ll2&tag=cvthunderx-20&linkId=de598040c2bae85024ff270880aef257&language=en_US&ref_=as_li_ss_tl
Discover our free courses in tech and cybersecurity, Start learning today:
https://linktr.ee/cybercode_academy
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Data Wrangling with JavaScript
I mean, it's a scenario that drives developers crazy every single day. We live in this world that's just overflowing with telemetry, user logs, sensor outputs, all of it. It's everywhere, it really is, and the pressure to extract immediate value from all of that is just immense. So the default assumption is always that you must pivot to a specialized language to get anything done.
So really, this is a survival guide for your data. You don't need to constantly switch gears and contexts, which is huge. So to kick things off, let's redefine some terms. Good idea, because there is this massive misconception in the tech world about what we were actually doing here. We hear data analysis and data wrangling used interchangeably basically all the time, all the time. Yeah, but they're vastly different beasts.
The end to end reality. I mean wrangling is acquiring the data from some remote server with a terrible connection. It's you know, figuring out how to store it efficiently on your local machines you can actually query it without waiting hours. It's exploring it just to see what kind of garbage was accidentally logged by a broken sensor.
Okay, let me try to put a mechanical lens on this, just to make sure we're on the same page. If data analysis is the engine of a car, like the thing actually generating the horsepower and the insights, then data wrangling is the chassis, the fuel lines, the transmission, the exhaust system.
Spot on the analysis is the core logic, sure, but the wrangling is the delivery mechanism that makes it usable. And in the real world, building that car isn't some neat linear process either an you mean, well, you don't just build the fuel line ones and you're done. You test it, you find leaks, you patch the then you realize the fuel itself is contaminated, so you have to go back and install a filter. The phases intersect and they loop back on themselves constantly. It's a very iterative process, which brings.
Oh absolutely, because Python, along with its data library pandas, are the undisputed heavyweight champions of the data world, No question. Python has the maturity, It has the academic backing the ecosystem. I mean, I can almost hear data scientists screaming at us right now through the speakers.
It's the single biggest point of friction in modern data teams. It's an So the alternative is radical, but it's entirely logical. Why not do your exploratory coding and your production coding in the exact same language. If you write your data pipeline in JavaScript from day one, you completely eliminate that translation phase.
So using JavaScript from start to finish just removes the middleman entirely precisely. Okay, the theory is incredibly compelling. You write the code once you avoid the translation bottlen like you stay native to the web. I get it, But theory only gets us so far raw data is inherently hostile.
Doesn't it. They are moving along these pre defined underwater paths called transits, and as they swim, they're pushing this specialized camera equipment that automatically snaps high resolution photos. But simultaneously it's capturing continuous sensor data things like water temperature, dive depth, visibility, all of that.
Breaks your concentration entirely. You can't work like that. So the strategic move is to decouple from the remote server. You write a short no JS script to query that SQL data once, just once, you pull it down over the network, and you save it locally on your own machine. But the author makes a highly specific choice here. They do not copy it into another local SQL database.
Okay, let me stop you there, because to me that feels really counterintuitive. How so well, SQL is highly structured, right right, forces you to define your tables and your data types. But Mongo dB is a no SQL database. It is notoriously schemeless. Aren't we basically inviting chaos by throwing away all the structure.
Throwing away the structure is the entire point during the exploratory phase. Wait, really, yes, think about it. When you are just starting to wrangle an unfamiliar data set, you don't actually know what the data looks like yet. True, if you try to force it into a local SEQL database, you carry this massive design burden right up front. You have to write scripts to define every single column. You have to guess the character limits, set the integer types, all before you can even import the first row.
That is a perfect analogy. Yes, with Mango dB you bypass the filing cabinet entirely. You just pour the data in. Wow, because it is schema less, it accepts whatever you give it. This reduces your upfront friction to basically zero, allowing your understanding of the data model to evolve naturally as you explore it. That makes a lot of sense actually, And there's another bonus. Mongo d B stores its data in bson, which is binary json.
But databases don't lie. However, sensors fail, networks drop packets, and humans mistype things all the time exactly, and you cannot manually scroll through eight hundred and twelve rows and fifty nine columns to find the errors with your own eyes. You have to write a JavaScript function to programmatically verify your assumptions.
That is the most common reaction, and it is strategically disastrous, really disastrous. Think back to your car analogy. If the spanometer shorts out, you don't rip out the entire dashboard and throw away the GPS location data, the gas gauge readings, and the odometer just because one dial broke.
The veteran data wrangler takes a different approach. You keep the raw data completely intact in your database, even the zeros, even the zeros. Instead, you adapt your processing logic. You write a filter in your JavaScript code that says, when calculating average temperatures later on, ignore the zero degree values, but keep them for calculating total dive distance.
Because a computer doesn't read it as a concept of time. It reads it as a sequence of dumb characters. Okay, it cannot perform temporal math on a string. You can't ask a string what day of the week was this or how many hours passed between this string and the next string, because it's just text exactly. But more dangerously, strings hide time zone assumptions. The divers in this study were off the coast of Australia. If you import that string data into a server running in New York, the timeline gets completely warped.
Imagine you want to group all the dives by the specific day they happened. A dive happens at eight am in Australia on a Tuesday, but your New York server, reading a dumb string, applies its own local system time. The time zone shift pushes that eight am dive backward over the midnight threshold into Monday. Oh no, suddenly your Tuesday averages are corrupted by Monday's data. Your visualizations will be completely inaccurate, and you won't even know why.
You utilize a specialized library like moment, dot js, or even just the built in modern JavaScript date objects. You write a script that iterates through the database, parses those messy strings, applies the explicit Australian time zone offset, and converts them into standardized, mathematically quantifiable date objects.
And now we need to transition from our back end server to the user's actual browser. The author sets up a lightweight web server using a framework called express dot chs right, and they build a rest API. So this acts as the bridge, taking our clean data from the local database and serving it over HTTP to a web page.
It communicates absolutely nothing. I mean it is technically accurate, sure, but practically useless. Right, But this failure actually highlights the incredible power of the single language pipeline we've been talking about. Oh, how so if this were the old Python too JavaScript workflow, realizing your chart is two dense might mean going all the way back to the Python team asking them to write a new export script and waiting days for a new CSV file to integrate.
Exactly. You jump back to you no JS script. You tweet the logic to filter the data down, perhaps focusing exclusively on say the Great Barrier reflocations. Okay, then instead of sending all the raw surveys to the browser, you modify your express API to only send the pre calculated averages per reach, which lighter the C three chart updates, immediately, transforming from a chaotic wall of color into a clean, legible, actionable comparison. The iteration loop is measured in seconds, not days, which brings us to.
Anything, But with the approach from Ashley Davis's book, there is no translation, none at all. None. Your exploratory data forge scripts, your quarantine filters, your express rest API, and your frontend C three charts are entirely written in JavaScript. Pushing this dashboard from your local laptop to a live production server is just a seamless evolution.
It's the ultimate productivity hack. Really, so for everyone listening right now, sitting at your desk, if you have a pile of MESSYCSV files where a massive database export that you have been dreading dealing with because you assume you need to enroll in like a six week Python boot camp to handle it, don't.
Your existing JavaScript knowledge isn't just for making buttons click or building UI components. It is a fully capable, high performance, end to end data engineering toolkit. You just have to stop looking at it purely as a front end language and start wielding it as a complete data pipeline.
And you know, as we continue to empower front end web developers to handle these complex, full scale data pipelines without needing specialized academic training. You really have to wonder, wonder, what does democratizing data wrangling naturally lead to a broader range of valuable insights? Or are we just making it faster and easier for people without formal statistical backgrounds to generate highly convincing, perfectly charted bad conclusions. Wow, something to think about next time you render a bar chart.
