A powerful, user-friendly Streamlit web application that transforms Excel spreadsheets into clean JSON data and SQL queries in seconds.
- Features
- Demo
- Installation
- Usage
- Configuration Options
- Technical Details
- API Reference
- Contributing
- License
- Excel File Upload: Support for both
.xlsxand.xlsfile formats - Multi-Sheet Support: Automatically detects and allows selection from multiple sheets within a workbook
- JSON Conversion: Convert Excel data to JSON with multiple orientation options
- SQL Generation: Generate
CREATE TABLEandINSERT INTOstatements for MySQL, PostgreSQL, and SQLite
- Intelligent Null Handling: Automatically detects and filters various null representations:
NA,null,Nonenan,nsnot available- Empty strings and whitespace-only values
- Column-Selective Cleaning: Choose specific columns for null filtering
- Real-time Statistics: View retained rows, dropped rows, and retention rate
- Modern UI: Clean, professional interface with custom CSS styling
- Data Preview: Preview raw and cleaned data before downloading
- SQL Preview Tabs: View
CREATE TABLE,INSERT INTO, and full SQL separately - Download Options: One-click download for both JSON and SQL outputs
Link to Project https://cell-to-set.streamlit.app/
- Upload your Excel file (.xlsx or .xls)
- Select the sheet to convert (if multiple sheets exist)
- Click "π Start Process"
- Review data overview and cleaning results
- Configure JSON/SQL options in the sidebar
- Download your converted JSON or SQL file
- Python 3.8 or higher
- pip package manager
-
Clone the repository:
git clone https://github.com/MrImaginatory/Cell_to_Set.git cd Excel_to_Json -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
streamlit run excelJson.py
-
Open your browser and navigate to
http://localhost:8501
- Upload File: Drag and drop or click to upload an Excel file
- Select Sheet: If the workbook contains multiple sheets, select the desired one
- Start Process: Click the "π Start Process" button to begin conversion
- Review Results: Check the data overview and cleaning statistics
- Download: Use the download buttons to save your JSON or SQL output
The application automatically cleans your data by:
- Converting various null representations to proper
NAvalues - Removing rows with invalid data in selected columns
- Preserving all valid data rows
Configure JSON output format in the sidebar:
| Orientation | Description |
|---|---|
records |
List of dictionaries (default, most common) |
columns |
Dictionary with column names as keys |
index |
Dictionary with row indices as keys |
values |
Nested array of values |
table |
Table schema format |
| Option | Description |
|---|---|
| Table Name | Custom name for the generated SQL table |
| SQL Dialect | Choose between MySQL, PostgreSQL, or SQLite |
- Orientation: Select the JSON structure format
- Indent Level: Control formatting indentation (0-4 spaces)
- Table Name: Specify the target table name (default:
my_table) - SQL Dialect: Choose target database:
- MySQL
- PostgreSQL
- SQLite
| Package | Purpose |
|---|---|
streamlit |
Web application framework |
pandas |
Data manipulation and Excel reading |
openpyxl |
Excel file format support |
| Pandas dtype | MySQL | PostgreSQL | SQLite |
|---|---|---|---|
int* |
INT | INTEGER | INT |
float* |
DOUBLE | DOUBLE PRECISION | REAL |
bool |
BOOLEAN | BOOLEAN | BOOLEAN |
datetime |
DATETIME | TIMESTAMP | DATETIME |
object/string |
VARCHAR(255) | TEXT | TEXT |
The application uses Streamlit's @st.cache_data decorator for:
get_sheet_names()- Caches sheet names for performanceload_data()- Caches loaded DataFrames
Retrieves all sheet names from an Excel file.
Parameters:
file: Uploaded Excel file object
Returns:
list: List of sheet names orNoneon error
Loads a specific sheet from an Excel file into a pandas DataFrame.
Parameters:
file: Uploaded Excel file objectsheet_name: Sheet name or index (default: 0)
Returns:
DataFrame: Loaded data orNoneon error
Cleans a DataFrame by converting null-like values and dropping invalid rows.
Parameters:
df: Input DataFrameselected_cols: List of columns to clean
Returns:
DataFrame: Cleaned DataFrame
Null Values Detected:
NA,null,None(case insensitive)nan,ns(case insensitive)not available(case insensitive)- Empty strings and whitespace
Sanitizes a column or table name for SQL compatibility.
Parameters:
name: Original name string
Returns:
str: Sanitized, lowercase name with underscores
Maps pandas data types to SQL column types.
Parameters:
dtype: pandas dtype objectdialect: Target SQL dialect ('mysql', 'postgresql', 'sqlite')
Returns:
str: SQL column type string
Generates CREATE TABLE and INSERT INTO SQL statements.
Parameters:
df: Input DataFrametable_name: Target table namedialect: SQL dialect for type mapping
Returns:
tuple: (create_statement, insert_statements)
- Page Title: "Cell to Set"
- Page Icon: β¨
- Layout: Wide
- Initial Sidebar State: Expanded
The application includes custom CSS for:
- Header styling (
.main-header,.sub-header) - Button hover effects
- Benefit cards for the landing page
- Metric value formatting
Excel_to_Json/
βββ excelJson.py # Main application file
βββ requirements.txt # Python dependencies
βββ README.md # Documentation
βββ .gitignore # Git ignore rules
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 guidelines
- Add docstrings to all functions
- Include type hints where appropriate
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or suggestions, please open an issue in the repository.
Made with β€οΈ for efficiency.