create

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package create has functions to create an SQLite3 database from a zipped CSV file.

Index

Constants

This section is empty.

Variables

View Source
var (
	MAX_ENTRIES int
)

Functions

func CreateDDL

func CreateDDL() string

This function creates a Data Definition Language (DDL) statement for creating a table called `voters`.

func CreateDatabase

func CreateDatabase(zipFileName, entryName, dbFileName string, progressEvery int) error

CreateDatabase is the mainline for creating a database from the zip file.

func CreateInsertSQL

func CreateInsertSQL(cols []string) string

CreateInsertSQL creates an SQL string that can be used for inserting records into the voters table.

func CreatePreparedStatement

func CreatePreparedStatement(tx *sql.Tx) (*sql.Stmt, error)

CreatePreparedStatement creates an SQL statement for inserting records into the voters table.

func GetSelectedIndices

func GetSelectedIndices(columns, selectedCols []string) []int

GetSelectedIndices returns the indices of selected columns from a given list of columns.

It takes two parameters:

  • 'columns' a slice of strings representing all available columns, and
  • 'selectedCols' - a slice of strings representing the columns that are selected.

The function iterates over the 'columns' slice, checks if each column exists in the 'selectedCols' slice, and if found, appends the index of the column to the 'selectedIndices' slice. Finally, it returns the 'selectedIndices' slice containing the indices of selected columns.

func GetZipEntry

func GetZipEntry(zipFileName string, entryName string) (*zip.File, error)

GetZipEntry gets a pointer to the embedded CSV file.

func IsSanitizeCol

func IsSanitizeCol(colName string) bool

IsSanitizeCol returns true if the specified column name is found in the list of columns that need to be sanitized.

func Sanitize

func Sanitize(input string) string

Sanitize takes a string parameter and returns a modified string by replacing multiple consecutive whitespace characters with a single space, and trimming leading and trailing whitespace.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL