Skip to main content
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.4k
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

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
  • 63.1k
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.3k
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.3k
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
  • 41k
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
  • 10.3k
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
9 votes

JSON data format for MCQ data bank

You have at least three factors to judge the formats by: Readability/intuitiveness (how easy are the formats to understand), Extensibility (how readily do the formats adapt to unforeseen needs), and ...
Seacow1427's user avatar
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
  • 32.4k
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
  • 41k
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,814
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.3k
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
  • 12.4k
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
7 votes
Accepted

Replacing values in json file with jq

Accessing environment variables in jq This doesn't really work as it is...: ...
janos's user avatar
  • 111k
7 votes
Accepted

Using an API to obtain JSON data and get the date string and determine if data is stale

You may also want to look at the Nagios::Plugin module or it's successor, Monitoring::Plugin. In these plugins, the OK, WARNING, CRITICAL and UNKNOWN exit statuses are exported by default, so you do ...
Tim B's user avatar
  • 86
7 votes
Accepted

Simple Product Inventory software using C# and OOP

: ...
404's user avatar
  • 2,306
7 votes
Accepted

Processing lots of JSON objects

LINQ (convenient) You could rewrite the loops with LINQ so this ...
t3chb0t's user avatar
  • 44.3k
7 votes
Accepted

Insert data to PostgreSQL

Do not use string formatting to pass parameters to SQL queries. This way you are not only getting type conversion and quotes balancing/escaping issues, but also making your code vulnerable to SQL ...
alecxe's user avatar
  • 17.3k
7 votes

Repeatable HTTP requests in Python

I'll start with the obvious: while submissions > 0: ... submissions -= 1 can be transformed into: ...
Cristian Lupascu's user avatar

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