Hot answers tagged

35 votes
Accepted

Filtering a large (50gb+) JSON lines file matching CIDR's

Is there a faster way of accomplishing this? Would Multithreading/Multiprocessing speed things up? Any help or other feedback would be much appreciated! No, for the most part, multi-threading will ...
rolfl's user avatar
  • 97.3k
17 votes
Accepted

User login database intended for beginners

Avoid wildcard imports from ... import * is not recommended. Especially when there are imports from multiple packages, it makes it difficult to know where some ...
janos's user avatar
  • 111k
16 votes
Accepted

Prettify JSON class

Thanks for editing the question. I have few ideas how you might want to polish your code. std::string base class It caught my eye that JSONPretify is derived ...
Jan Korous's user avatar
16 votes
Accepted

Parsing overly complex JSON

Globals # TO-DO: GET RID OF GLOBAL STATE Yep. You seem to already understand this one. Having a reset betrays a place in your ...
Reinderien's user avatar
  • 58.2k
15 votes

JSON Parsing in Bash

Bash is not well-suited for transforming JSON. But jq is. But calling jq 3 times for each line of input is certainly going to be ...
janos's user avatar
  • 111k
13 votes
Accepted

Current ISS latitude / longitude position

Currently your code is not re-useable. To make it re-useable you should move the logic inside a function. To do this the function we will have two functions here: ...
Ashwini Chaudhary's user avatar
13 votes
Accepted

Minecraft block generator

I won't repeat @victor's answer, but Python is a language that comes with batteries included; meaning that a lot of behaviour has already been bundled into modules, and is maintained for correctness ...
301_Moved_Permanently's user avatar
12 votes

User login database intended for beginners

Your code is confusing, since it refers to encryption in multiple places, e.g. the filename encryption.py, the function name ...
Jörg W Mittag's user avatar
12 votes
Accepted

CodeReview question markdown downloader

PyCharm complains on this line: m = json.loads(data) If the above call to fetch_compressed_data fails, and the resulting ...
Carcigenicate's user avatar
11 votes
Accepted

A minimal CLI password storage and retrieval manager

I would pinpoint the major problems in the code which I would address first: do not manually handle provided command-line arguments - there is a great built-in module for it - ...
alecxe's user avatar
  • 17.2k
11 votes

Parsing a JSON file upload

Here are my comments, in order of severity: Bugs (or bug-like behavior) Resource leaks: You do not close any of the IO resources that you use (DB connection and various ...
Sharon Ben Asher's user avatar
10 votes

Current ISS latitude / longitude position

The code is clean and understandable. There are only minor improvements that we can apply. use more descriptive variable names: latitude_direction and ...
alecxe's user avatar
  • 17.2k
10 votes
Accepted

Repeatable HTTP requests in Python

If you are making many requests, it is worth it to have a look at requests.Session. This re-uses the connection to the server for subsequent requests (and also the ...
Graipher's user avatar
  • 40.8k
10 votes

Minecraft block generator

If all you need is just readability and maintainability, and general best practice, don't reinvent the wheel. You have the json library and it would be a sin not to use it. Firstly, you are greatly ...
Victor's user avatar
  • 420
10 votes

CodeReview question markdown downloader

Just a couple stylistic points Function/Variable Naming Functions and variables should be in snake_case (PEP 8). ...
Linny's user avatar
  • 9,948
9 votes

Spring Boot RESTful service

Should be changed: Request mappings are not that RESTful due to the verbs: POST /api/cars/add-car => POST /api/cars ...
Lyubomyr Shaydariv's user avatar
9 votes
Accepted

Elegantly combine list of records into JSON for a Python post request?

I fail to see a reason for the long way around. If you already have parsed JSON, why not use it directly? ...
Richard Neumann's user avatar
8 votes

From Q to compiler in less than 30 seconds

I have a couple of suggestions which are not specifically about the code, but rather about the user experience. The first thing I did was copy-paste the script to a file, make it executable and tried ...
jacwah's user avatar
  • 2,661
8 votes
Accepted

Convert all CSV files in a given directory to JSON using Python

Looks good to me. It's a perfectly sensible approach. There's just one line I'm going to criticize: csvfile = os.path.splitext(filename)[0] Picking off ...
J_H's user avatar
  • 13.8k
8 votes

User login database intended for beginners

This is also not a very good design from the viewpoint of algorithmic complexity. Whenever you want to check if a user already exists, or to retrieve a user, you need to read the whole file content. ...
Graipher's user avatar
  • 40.8k
8 votes
Accepted

Using decorated methods in a subclass of deque to dump its state to a JSON file

I don't think that what you're doing is good style. I think you're adding a lot of extra complexity and places for things to go wrong, or become hard to understand, or whatever. I don't think you lose ...
Dan Oberlam's user avatar
  • 7,744
8 votes
Accepted

Should my Json storage handle exceptions?

This is how I see things... Throwing ArgumentException insinde a try/catch that at the same time swollows it is pointless. You ...
t3chb0t's user avatar
  • 44.1k
8 votes

CodeReview question markdown downloader

Improving HTTP communication scheme Instead of urllib.request/urllib.error use requests lib as well-known, elegant and simple ...
RomanPerekhrest's user avatar
8 votes
Accepted

JSON reader based on a pushdown automata

I’m going to review your code in the order you’ve presented it in the opening post, simply because that’s the most orderly way to go about it from my perspective. I’ll mention overarching design ...
indi's user avatar
  • 9,781
7 votes
Accepted

Parsing JSON in one go

First of all, let me say well done on the progress made from your first question to now! Code Review is for reviewing code As you seem to be seeking advice "about how to implement" an idea (i.e. ...
Tersosauros's user avatar
7 votes

Tracking Containers in a Train Station

...
Pimgd's user avatar
  • 22.3k
7 votes

Tracking Containers in a Train Station

I'm really sorry, but after starting this review I have to tell you: Go back, read some more tutorials and try again This code has so many issues, that I'm not able to point them out reasonably ...
Vogel612's user avatar
  • 25.2k
7 votes
Accepted

From Q to compiler in less than 30 seconds

My answer's short because I don't see much wrong with it, but this is what I think: In fetch_compressed_data(), you define data ...
zondo's user avatar
  • 3,787
7 votes

Showing virus scan results from an API and a CSV file

I think that I am brute forcing my way to some of the text fields I am looking for. Indeed. csv.reader() Each row returned by ...
scottbb's user avatar
  • 872
7 votes

Determine if a file is either in JSON or XML format

Well, if you only need to distinguish between JSON and XML formats I'd keep it simple. If the encoding of that string is known ...
Grajdeanu Alex's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible