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 ...
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 ...
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 ...
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: ...
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 ...
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 ...
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 ...
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 - ...
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 ...
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 ...
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 ...
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 ...
10
votes
CodeReview question markdown downloader
Just a couple stylistic points
Function/Variable Naming
Functions and variables should be in snake_case (PEP 8).
...
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
...
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?
...
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
...
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 ...
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. ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
7
votes
Accepted
Replacing values in json file with jq
Accessing environment variables in jq
This doesn't really work as it is...:
...
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 ...
7
votes
Accepted
7
votes
Accepted
Processing lots of JSON objects
LINQ (convenient)
You could rewrite the loops with LINQ so this
...
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 ...
7
votes
Repeatable HTTP requests in Python
I'll start with the obvious:
while submissions > 0:
...
submissions -= 1
can be transformed into:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
json × 872javascript × 220
python × 218
java × 90
c# × 88
python-3.x × 67
beginner × 66
php × 64
api × 62
performance × 61
parsing × 59
jquery × 58
c++ × 36
object-oriented × 30
node.js × 30
http × 28
html × 26
csv × 26
array × 24
ajax × 23
swift × 21
python-2.x × 19
mysql × 18
serialization × 18
ecmascript-6 × 17