Skip to main content
12 votes
Accepted

Why should imports be made at the beginning

Here are the benefits of the imports at the top of the file: As soon as I open the file, I can see all its dependencies. I know it's using datetime or os, because I can immediately see the imports ...
Arseni Mourzenko's user avatar
7 votes

Import large csv files

A Stream does not need to read the entire file into memory, so... Don't bother with Excel at all if you can accumulate needed information while reading records: Sum as records are read Build a ...
radarbob's user avatar
  • 5,823
7 votes

System Design: Very Large CSV Imports Every Month

"CSV" is not the right word for what they deliver you. It's the format they deliver it to you in, and with very weak guarantees. Most people refer to a 6 GB CSV file with unreliable and missing data ...
djechlin's user avatar
  • 2,222
6 votes
Accepted

Is importing wildcards a bad idea?

It is not a bad idea, but it does have some consequences you should be aware of. It's a tradeoff. Its simpler and shorter, and less programmer overhead typing crap. And its probably less likely to ...
Lewis Pringle's user avatar
5 votes
Accepted

Python Unit Tests Mocking Imports - Removing Dependencies for CI/CD

Create an abstraction layer that wraps whatever functionality you need from the data base. Create a trivial mock implementation to be used in unit tests. Create a second almost as trivial ...
Kilian Foth's user avatar
4 votes
Accepted

Import large csv files

I do not know which, from the other answers, will work best for you. AFAICT, I'd remark, mostly from an implementation standpoint, that they all make sense, but from a design perspective, which one ...
YSharp's user avatar
  • 888
4 votes

Import large csv files

Ummm...Use Excel. Excel can import CSV files. All the functionality you describe here can be done in Excel. If these are recurring tasks, you could write some macros to automate the loading of the ...
Jon Raynor's user avatar
  • 11.6k
3 votes
Accepted

Why don't languages auto import everything?

As a software developer, I don't want my compiler to import anything unless I tell it to. Just because a package is "available", doesn't mean I trust it. And I certainly want to be able to ...
gnasher729's user avatar
  • 45.8k
3 votes

Why don't languages auto import everything?

'import' allows to you select just those features you need from other packages, libraries and/or modules in your application. Since a package is often a whole set of files and/or binaries and ...
incongruentDoughnut's user avatar
3 votes

Import large csv files

Of course you can use bulk import. If you can't access the corporate database for some reasons, you install one locally and use it. Since you seem to be working with Microsoft's stack, SQL Server ...
Arseni Mourzenko's user avatar
3 votes

System Design: Very Large CSV Imports Every Month

This depends heavily on the requirements, what "enter, correct, and flag/delete data" exactly means, and your further requirements for preprocessing and postprocessing. Is the editing done on a per-...
Doc Brown's user avatar
  • 209k
3 votes

Why is it necessary to "import" a library first before usage?

I can think of three main reasons for it: The name of a function or class could be ambiguous. There are dozens of image handling libraries. From which one do I want to use the Image class? In the ...
whatsisname's user avatar
  • 27.6k
2 votes

Store line numbers of CSV in the database

There is no general design rule for storing or not storing line or record numbers of a CSV file. You store them when you have a requirement for storing them (like you want to to store the file line-by-...
Doc Brown's user avatar
  • 209k
2 votes

Why is it necessary to "import" a library first before usage?

What you suggest is possible in some languages like Java and C#: If you use the fully qualified name of the class you want to use, you don't need to explicitly import anything, the environment will ...
JacquesB's user avatar
  • 59.8k
2 votes

Python dynamically import modules

I finally found how to do this. On the init file I loaded all modules and returned them as a dictionary. Code for __init__.py: from pkgutil import iter_modules from pathlib import Path from importlib ...
bkbilly's user avatar
  • 131
2 votes

Strictly only importing modules in subdirectories: is this a good rule?

Keeping a clear dependency graph is a good thing, because the results can be a bit unexpected when two modules import each other. However: Only importing child modules is probably a bit restrictive. ...
amon's user avatar
  • 134k
2 votes
Accepted

How to use lazy import to speed up a list of known types in python?

The easiest solution is indeed going to be to describe the model via strings describing the module that you then import. For example, something like: import importlib KNOWN_TYPES = { "kmeans&...
amon's user avatar
  • 134k
2 votes

Is it bad practice to export all the names from one module both as named exports and as a default export?

At first glance I had mixed feelings about this. On one hand, it is convenient because it saves you a few lines of code when using the module. In the other hand, it makes some assumptions about how ...
Greg Burghardt's user avatar
2 votes

What's the best way to import a python module in a python module without cluttering the modules namepace?

You wrote import abc as _abc Don't do that; it makes your code harder to read. A simple import abc suffices. I would expect renames such as _abc to be called out during code review, so the PR wouldn'...
J_H's user avatar
  • 7,320
1 vote

Why don't languages auto import everything?

The main reason is code organization and readability. Almost all programming languages have some idea of namespaces or modules - something that allows name reuse within a context. By default this ...
Michael's user avatar
  • 6,467
1 vote
Accepted

Better design for a REST import into web store

I would add an additional layer here that hides the abstraction better. The RunImport method should only have a high-level view over the import process, the details of each individual import should be ...
Flater's user avatar
  • 52.1k
1 vote
Accepted

Transferring data from 1 web app into another offline

As Doc Brown said, there's no generic solution for that! I would still advise you revisit your limitations, as you need to consider the total cost of ownership, IMHO. A cloud database may end up ...
thinkOfaNumber's user avatar
1 vote

Transferring data from 1 web app into another offline

I've tried to search solution but there is no general answer Yep, that's correct, there is no general answer. There is data in your original database which has to be exported to another one. However, ...
Doc Brown's user avatar
  • 209k
1 vote

Component based architectures in JS / PHP: what indicators suggest that a UI element ought to be written as an importable component?

The best approach to thinking about this I have come up with is to ask the following two questions: 1) Does the UI Element represent an enhancement to the document? (ie. would the document remain ...
Rounin's user avatar
  • 285
1 vote

Are legacy C# DataTable/SqlDataAdapters exponentially faster than SqlConnection/SqlCommand and/or LINQ to SQL DataContext.ExecuteCommand calls?

Excellent analysis. Writing an object graph is notoriously difficult because it can involve a lot of foreign key lookups and these are hard to implement without incurring a lot of waits. To make a ...
Martin K's user avatar
  • 2,917
1 vote

Why should imports be made at the beginning

It helps understanding the code because you see all dependencies at first sight. Long lists of imports and long files are a sign of bad design with too many dependencies. Such files should be ...
Frank Puffer's user avatar
  • 6,429
1 vote

Is importing wildcards a bad idea?

Bad idea. You rely on a kind of smartness inappropriate at the compiler level. Import statements serve a documentation purpose: the reader gets an idea about the covered domains of the class. This is ...
Martin Maat's user avatar
  • 18.4k
1 vote

System Design: Very Large CSV Imports Every Month

A solution we adopted was to create mappings. The tool would grab the first n rows of data skipping anything that looked like boilerplate so that the person handling the import would be able to see a ...
Berin Loritsch's user avatar
1 vote
Accepted

Maintainable way for keeping objects in memory

Some objects that need to be accessed from multiple menus sit in their own file where they are saved to a variable and imported into the "highest-level" file (main.py) so they aren't ...
candied_orange's user avatar
1 vote

Best way to import a large module to use in different modules

First, if you can, put the data initialisation into a function (so initialisation won't happen on import). This helps with testing etc. You can use multiprocessing.sharedctypes to create variables ...
Epic Wink's user avatar
  • 207

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