#C13913. SQLite Database Table Analysis

    ID: 43504 Type: Default 1000ms 256MiB

SQLite Database Table Analysis

SQLite Database Table Analysis

Your task is to create a program that connects to an SQLite database, retrieves data from a specified table, and produces summary statistics of the retrieved data. The summary statistics should mimic the output of DataFrame.describe() in pandas and must be printed to standard output in CSV format.

The summary includes key statistical measures in LaTeX format:

$$\text{count},\;\text{mean},\;\text{std},\;\text{min},\;\text{25\%},\;\text{50\%},\;\text{75\%},\;\text{max}$$

Your program should robustly handle potential issues such as database connection failures or data processing errors. If an error occurs, an appropriate error message should be printed to stdout.

Input Details:

  • The program will receive three lines from stdin:
  • 1. The path to the SQLite database file.
  • 2. The name of the table to query.
  • 3. A CSV file path (this input is read but not used for output as the CSV content is printed to stdout).

Output Details:

  • If the operation is successful, the program prints the CSV representation of the summary statistics.
  • If a database connection error occurs, print a message starting with Database error:
  • If a data processing error occurs (for example, the table does not exist), print a message starting with Data processing error:

inputFormat

The input consists of three lines read from standard input:

line1: Path to the SQLite database file (string)
line2: Table name to query (string)
line3: CSV file path (string, but ignored for output)

Example:

test_db.sqlite
test_table
summary.csv

outputFormat

If successful, the program prints the CSV representation of the summary statistics computed from the table. The first row should be the header with statistical metrics and subsequent rows represent the summary for each column. If there is an error, an error message is printed to stdout.

## sample
test_db.sqlite
test_table
summary.csv
count,mean,std,min,25%,50%,75%,max