This article presents an open-source tool that is able to process local and remote CSV files, load and print the information, and later map the column to Django Types. Processing CSV files is usually required when the dataset becomes large, custom reports are unsupported by Excel or full data manipulation via data tables, and API is needed. The current list of features can be further extended to map CSV files to database tables/models and fully generate dashboard web apps.
Before we start explaining the code and the usage, let's summarize the tool features:
load local and remote files
print values
print detected column types
print the mapping types to a Django Model
The CSV parser can be executed via the CLI after cloning the project sources and making it usable as explained in the README. Once the installation is completed, we can call the CVS processor using this one-liner:
locate the CSV file (exit with error if not found)
loads the information and detects the column types
detects the Django column type
print the first 10 rows
The same can be applied to local and remote files. For instance, we can analyze the notorious Titanic.cvs by running this one-liner:
Here are the relevant parts of the tool:
Loads the information and prior checks the source if is local or remote
Analyze the headers and map the detected types to Django Types.
For the tabular view, Tabulate Library is used:
The last step is to Print the CSV data:
At this point, the code provides us access to the CSV information, data types, and the correspondent data types for Django. The mapping can be easily extended for any framework like Flask, Express, or NextJS.
The type mapping for Django is this one:
This tool is under active development and here are the next steps:
connect the tool to more data sources like remote/local databases (SQLite, MySql, PgSQL), JSON
Generate Models for any framework: FastAPI, Flask, Express, NextJS
Generate secure APIs on top
Generate server-side paginated DataTables using Tailwind/Bootstrap for styling
Thanks for reading!
For those interested in contributing, feel free to join the new AppSeed platform and connect with the community on Discord: